Exemplo n.º 1
0
/**
 * Commits a tree to the master branch of the repository.
 */
static int sync_commit_master(git_repository *repo,
                              const char *message,
                              git_oid *tree_id,
                              size_t parent_count,
                              const git_oid *parents[])
{
    int e = 0;
    git_signature *sig = NULL;
    git_oid commit_id;

    git_check(git_signature_now(&sig, SYNC_GIT_NAME, SYNC_GIT_EMAIL));

    git_check(git_commit_create_from_ids(&commit_id, repo, SYNC_REF_MASTER,
        sig, sig, NULL, message,
        tree_id, parent_count, parents));

exit:
    if (sig)            git_signature_free(sig);
    return e;
}
Exemplo n.º 2
0
void test_clone_nonetwork__clone_submodule(void)
{
	git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
	git_index *index;
	git_oid tree_id, commit_id;
	git_submodule *sm;
	git_signature *sig;
	git_repository *sm_repo;

	cl_git_pass(git_repository_init(&g_repo, "willaddsubmodule", false));


	/* Create the submodule structure, clone into it and finalize */
	cl_git_pass(git_submodule_add_setup(&sm, g_repo, cl_fixture("testrepo.git"), "testrepo", true));

	clone_opts.repository_cb = just_return_repo;
	clone_opts.repository_cb_payload = sm;
	clone_opts.remote_cb = just_return_origin;
	clone_opts.remote_cb_payload = sm;
	cl_git_pass(git_clone(&sm_repo, cl_fixture("testrepo.git"), "testrepo", &clone_opts));
	cl_git_pass(git_submodule_add_finalize(sm));
	git_repository_free(sm_repo);
	git_submodule_free(sm);

	cl_git_pass(git_repository_index(&index, g_repo));
	cl_git_pass(git_index_write_tree(&tree_id, index));
	git_index_free(index);

	cl_git_pass(git_signature_now(&sig, "Submoduler", "submoduler@local"));
	cl_git_pass(git_commit_create_from_ids(&commit_id, g_repo, "HEAD", sig, sig, NULL, "A submodule\n",
					       &tree_id, 0, NULL));

	git_signature_free(sig);

	assert_submodule_exists(g_repo, "testrepo");
}