예제 #1
0
파일: local.c 프로젝트: rlugojr/libgit2
void test_network_remote_local__update_tips_for_new_remote(void) {
    git_repository *src_repo;
    git_repository *dst_repo;
    git_remote *new_remote;
    git_reference* branch;

    /* Copy test repo */
    cl_fixture_sandbox("testrepo.git");
    cl_git_pass(git_repository_open(&src_repo, "testrepo.git"));

    /* Set up an empty bare repo to push into */
    cl_git_pass(git_repository_init(&dst_repo, "./localbare.git", 1));

    /* Push to bare repo */
    cl_git_pass(git_remote_create(&new_remote, src_repo, "bare", "./localbare.git"));
    cl_git_pass(git_remote_push(new_remote, &push_array, NULL));
    /* Make sure remote branch has been created */
    cl_git_pass(git_branch_lookup(&branch, src_repo, "bare/master", GIT_BRANCH_REMOTE));

    git_reference_free(branch);
    git_remote_free(new_remote);
    git_repository_free(dst_repo);
    cl_fixture_cleanup("localbare.git");
    git_repository_free(src_repo);
    cl_fixture_cleanup("testrepo.git");
}
예제 #2
0
void test_diff_submodules__cleanup(void)
{
	cl_git_sandbox_cleanup();

	cl_fixture_cleanup("testrepo.git");
	cl_fixture_cleanup("submod2_target");
}
예제 #3
0
파일: clone.c 프로젝트: RsrchBoy/p5-Git-Raw
void test_online_clone__bitbucket_style(void)
{
	git_cred_userpass_payload user_pass = {
		"libgit2", "libgit2"
	};

	g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
	g_options.fetch_opts.callbacks.payload = &user_pass;

	cl_git_pass(git_clone(&g_repo, BB_REPO_URL, "./foo", &g_options));
	git_repository_free(g_repo); g_repo = NULL;
	cl_fixture_cleanup("./foo");

	/* User and pass from URL */
	user_pass.password = "******";
	cl_git_pass(git_clone(&g_repo, BB_REPO_URL_WITH_PASS, "./foo", &g_options));
	git_repository_free(g_repo); g_repo = NULL;
	cl_fixture_cleanup("./foo");

	/* Wrong password in URL, fall back to user_pass */
	user_pass.password = "******";
	cl_git_pass(git_clone(&g_repo, BB_REPO_URL_WITH_WRONG_PASS, "./foo", &g_options));
	git_repository_free(g_repo); g_repo = NULL;
	cl_fixture_cleanup("./foo");
}
예제 #4
0
파일: setters.c 프로젝트: 1336/libgit2
void test_repo_setters__cleanup(void)
{
	git_repository_free(repo);
	repo = NULL;

	cl_fixture_cleanup("testrepo.git");
	cl_fixture_cleanup("new_workdir");
}
예제 #5
0
파일: tests.c 프로젝트: 1336/libgit2
/* Test that writing an invalid filename fails */
void test_index_tests__add_invalid_filename(void)
{
	git_repository *repo;

	p_mkdir("invalid", 0700);

	cl_git_pass(git_repository_init(&repo, "./invalid", 0));
	cl_must_pass(p_mkdir("./invalid/subdir", 0777));

	/* cl_git_mkfile() needs the dir to exist */
	if (!git_path_exists("./invalid/.GIT"))
		cl_must_pass(p_mkdir("./invalid/.GIT", 0777));
	if (!git_path_exists("./invalid/.GiT"))
		cl_must_pass(p_mkdir("./invalid/.GiT", 0777));

	add_invalid_filename(repo, ".git/hello");
	add_invalid_filename(repo, ".GIT/hello");
	add_invalid_filename(repo, ".GiT/hello");
	add_invalid_filename(repo, "./.git/hello");
	add_invalid_filename(repo, "./foo");
	add_invalid_filename(repo, "./bar");
	add_invalid_filename(repo, "subdir/../bar");

	git_repository_free(repo);

	cl_fixture_cleanup("invalid");
}
예제 #6
0
파일: clone.c 프로젝트: jasperla/libgit2
void test_online_clone__credentials(void)
{
    /* Remote URL environment variable must be set.
     * User and password are optional.
     */
    const char *remote_url = cl_getenv("GITTEST_REMOTE_URL");
    git_cred_userpass_payload user_pass = {
        cl_getenv("GITTEST_REMOTE_USER"),
        cl_getenv("GITTEST_REMOTE_PASS")
    };

    if (!remote_url) return;

    if (cl_getenv("GITTEST_REMOTE_DEFAULT")) {
        g_options.remote_callbacks.credentials = cred_default;
    } else {
        g_options.remote_callbacks.credentials = git_cred_userpass;
        g_options.remote_callbacks.payload = &user_pass;
    }

    cl_git_pass(git_clone(&g_repo, remote_url, "./foo", &g_options));
    git_repository_free(g_repo);
    g_repo = NULL;
    cl_fixture_cleanup("./foo");
}
예제 #7
0
void test_object_commit_commitstagedfile__cleanup(void)
{
	git_repository_free(repo);
	repo = NULL;

	cl_fixture_cleanup("treebuilder");
}
예제 #8
0
static void cleanup_fixture_submodules(void *payload)
{
	cl_git_sandbox_cleanup(); /* either "submodules" or "submod2" */

	if (payload)
		cl_fixture_cleanup(payload);
}
예제 #9
0
파일: remotelocal.c 프로젝트: gitpan/Git-XS
void test_network_remotelocal__cleanup(void)
{
	git_remote_free(remote);
	git_buf_free(&file_path_buf);
	git_repository_free(repo);
	cl_fixture_cleanup("remotelocal");
}
예제 #10
0
파일: create.c 프로젝트: Asquera/libgit2
void test_refs_branches_create__cleanup(void)
{
	git_object_free(target);
	git_repository_free(repo);

	cl_fixture_cleanup("testrepo.git");
}
예제 #11
0
파일: init.c 프로젝트: Arhzi/libgit2
static void cleanup_repository(void *path)
{
	git_repository_free(_repo);
	_repo = NULL;

	cl_fixture_cleanup((const char *)path);
}
예제 #12
0
파일: local.c 프로젝트: rlugojr/libgit2
void test_network_remote_local__push_to_non_bare_remote(void)
{
    char *refspec_strings[] = {
        "master:master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };
    /* Shouldn't be able to push to a non-bare remote */
    git_remote *localremote;
    git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;

    /* Get some commits */
    connect_to_local_repository(cl_fixture("testrepo.git"));
    cl_git_pass(git_remote_fetch(remote, &array, &fetch_opts, NULL));

    /* Set up an empty non-bare repo to push into */
    {
        git_repository *remoterepo = NULL;
        cl_git_pass(git_repository_init(&remoterepo, "localnonbare", 0));
        git_repository_free(remoterepo);
    }

    /* Connect to the bare repo */
    cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
    cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));

    /* Try to push */
    cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));

    /* Clean up */
    git_remote_free(localremote);
    cl_fixture_cleanup("localbare.git");
}
예제 #13
0
파일: local.c 프로젝트: rlugojr/libgit2
void test_network_remote_local__push_to_bare_remote(void)
{
    char *refspec_strings[] = {
        "master:master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };

    /* Should be able to push to a bare remote */
    git_remote *localremote;

    /* Get some commits */
    connect_to_local_repository(cl_fixture("testrepo.git"));
    cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL));

    /* Set up an empty bare repo to push into */
    {
        git_repository *localbarerepo;
        cl_git_pass(git_repository_init(&localbarerepo, "./localbare.git", 1));
        git_repository_free(localbarerepo);
    }

    /* Connect to the bare repo */
    cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
    cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));

    /* Try to push */
    cl_git_pass(git_remote_upload(localremote, &push_array, NULL));

    /* Clean up */
    git_remote_free(localremote);
    cl_fixture_cleanup("localbare.git");
}
예제 #14
0
파일: clone.c 프로젝트: DonkeyWs/libgit2
void test_online_clone__clone_mirror(void)
{
	git_buf path = GIT_BUF_INIT;
	git_remote *remote;
	git_reference *head;
	git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;

	bool fetch_progress_cb_was_called = false;

	cl_git_pass(git_repository_init(&g_repo, "./foo.git", true));
	cl_git_pass(git_remote_create(&remote, g_repo, "origin", LIVE_REPO_URL));

	callbacks.transfer_progress = &fetch_progress;
	callbacks.payload = &fetch_progress_cb_was_called;
	git_remote_set_callbacks(remote, &callbacks);

	git_remote_clear_refspecs(remote);
	cl_git_pass(git_remote_add_fetch(remote, "+refs/*:refs/*"));

	cl_git_pass(git_clone_into(g_repo, remote, NULL, NULL, NULL));

	cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
	cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
	cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));

	cl_assert_equal_i(true, fetch_progress_cb_was_called);

	git_remote_free(remote);
	git_reference_free(head);
	git_buf_free(&path);
	git_repository_free(g_repo);
	g_repo = NULL;

	cl_fixture_cleanup("./foo.git");
}
예제 #15
0
파일: delete.c 프로젝트: Asquera/libgit2
void test_refs_branches_delete__cleanup(void)
{
	git_reference_free(fake_remote);
	git_repository_free(repo);

	cl_fixture_cleanup("testrepo.git");
}
예제 #16
0
파일: tests.c 프로젝트: lznuaa/libgit2
/* Test that writing an invalid filename fails */
void test_index_tests__write_invalid_filename(void)
{
	git_repository *repo;
	git_index *index;
	git_oid expected;

	p_mkdir("read_tree", 0700);

	cl_git_pass(git_repository_init(&repo, "./read_tree", 0));
	cl_git_pass(git_repository_index(&index, repo));

	cl_assert(git_index_entrycount(index) == 0);

	cl_git_mkfile("./read_tree/.git/hello", NULL);

	cl_git_pass(git_index_add_bypath(index, ".git/hello"));

	/* write-tree */
	cl_git_fail(git_index_write_tree(&expected, index));

	git_index_free(index);
	git_repository_free(repo);

	cl_fixture_cleanup("read_tree");
}
예제 #17
0
파일: commit.c 프로젝트: DonkeyWs/libgit2
void test_commit_commit__cleanup(void)
{
	git_repository_free(_repo);
	_repo = NULL;

	cl_fixture_cleanup("testrepo.git");
}
예제 #18
0
파일: tests.c 프로젝트: 1336/libgit2
void test_index_tests__remove_entry(void)
{
	git_repository *repo;
	git_index *index;

	p_mkdir("index_test", 0770);

	cl_git_pass(git_repository_init(&repo, "index_test", 0));
	cl_git_pass(git_repository_index(&index, repo));
	cl_assert(git_index_entrycount(index) == 0);

	cl_git_mkfile("index_test/hello", NULL);
	cl_git_pass(git_index_add_bypath(index, "hello"));
	cl_git_pass(git_index_write(index));

	cl_git_pass(git_index_read(index, true)); /* reload */
	cl_assert(git_index_entrycount(index) == 1);
	cl_assert(git_index_get_bypath(index, "hello", 0) != NULL);

	cl_git_pass(git_index_remove(index, "hello", 0));
	cl_git_pass(git_index_write(index));

	cl_git_pass(git_index_read(index, true)); /* reload */
	cl_assert(git_index_entrycount(index) == 0);
	cl_assert(git_index_get_bypath(index, "hello", 0) == NULL);

	git_index_free(index);
	git_repository_free(repo);
	cl_fixture_cleanup("index_test");
}
예제 #19
0
void test_index_addall__cleanup(void)
{
	git_repository_free(g_repo);
	g_repo = NULL;

	cl_fixture_cleanup(TEST_DIR);
}
예제 #20
0
파일: init.c 프로젝트: Arhzi/libgit2
void test_repo_init__extended_with_template_and_shared_mode(void)
{
	git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
	int filemode = true;
	const char *repo_path = NULL;

	cl_set_cleanup(&cleanup_repository, "init_shared_from_tpl");
	template_sandbox("template");

	opts.flags = GIT_REPOSITORY_INIT_MKPATH |
		GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
	opts.template_path = "template";
	opts.mode = GIT_REPOSITORY_INIT_SHARED_GROUP;

	cl_git_pass(git_repository_init_ext(&_repo, "init_shared_from_tpl", &opts));

	cl_assert(!git_repository_is_bare(_repo));
	cl_assert(!git__suffixcmp(git_repository_path(_repo), "/init_shared_from_tpl/.git/"));

	filemode = cl_repo_get_bool(_repo, "core.filemode");

	repo_path = git_repository_path(_repo);
	assert_mode_seems_okay(repo_path, "hooks",
		GIT_FILEMODE_TREE | GIT_REPOSITORY_INIT_SHARED_GROUP, true, filemode);
	assert_mode_seems_okay(repo_path, "info",
		GIT_FILEMODE_TREE | GIT_REPOSITORY_INIT_SHARED_GROUP, true, filemode);
	assert_mode_seems_okay(repo_path, "description",
		GIT_FILEMODE_BLOB, false, filemode);

	validate_templates(_repo, "template");

	cl_fixture_cleanup("template");
}
예제 #21
0
파일: init.c 프로젝트: Arhzi/libgit2
void test_repo_init__external_templates_with_leading_dot(void)
{
	git_buf template_path = GIT_BUF_INIT;

	git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;

	cl_set_cleanup(&cleanup_repository, "templated.git");
	template_sandbox("template");

	cl_must_pass(p_rename("template", ".template_with_leading_dot"));

	cl_git_pass(git_buf_joinpath(&template_path, clar_sandbox_path(),
		".template_with_leading_dot"));

	configure_templatedir(template_path.ptr);

	opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
		GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;

	cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));

	validate_templates(_repo, ".template_with_leading_dot");
	cl_fixture_cleanup(".template_with_leading_dot");

	git_buf_free(&template_path);
}
예제 #22
0
void test_diff_workdir__submodules(void)
{
	const char *a_commit = "873585b94bdeabccea991ea5e3ec1a277895b698";
	git_tree *a;
	git_diff_options opts = {0};
	git_diff_list *diff = NULL;
	diff_expects exp;

	g_repo = cl_git_sandbox_init("submod2");

	cl_fixture_sandbox("submod2_target");
	p_rename("submod2_target/.gitted", "submod2_target/.git");

	rewrite_gitmodules(git_repository_workdir(g_repo));
	p_rename("submod2/not_submodule/.gitted", "submod2/not_submodule/.git");

	cl_fixture_cleanup("submod2_target");

	a = resolve_commit_oid_to_tree(g_repo, a_commit);

	opts.flags =
		GIT_DIFF_INCLUDE_UNTRACKED |
		GIT_DIFF_RECURSE_UNTRACKED_DIRS |
		GIT_DIFF_INCLUDE_UNTRACKED_CONTENT;

	cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff));

	/* diff_print(stderr, diff); */

	/* essentially doing: git diff 873585b94bdeabccea991ea5e3ec1a277895b698 */

	memset(&exp, 0, sizeof(exp));
	cl_git_pass(git_diff_foreach(
		diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));

	/* the following differs from "git diff 873585" by one "untracked" file
	 * because the diff list includes the "not_submodule/" directory which
	 * is not displayed in the text diff.
	 */

	cl_assert_equal_i(10, exp.files);

	cl_assert_equal_i(0, exp.file_adds);
	cl_assert_equal_i(0, exp.file_dels);
	cl_assert_equal_i(1, exp.file_mods);
	cl_assert_equal_i(0, exp.file_ignored);
	cl_assert_equal_i(9, exp.file_untracked);

	/* the following numbers match "git diff 873585" exactly */

	cl_assert_equal_i(9, exp.hunks);

	cl_assert_equal_i(33, exp.lines);
	cl_assert_equal_i(2, exp.line_ctxt);
	cl_assert_equal_i(30, exp.line_adds);
	cl_assert_equal_i(1, exp.line_dels);

	git_diff_list_free(diff);
	git_tree_free(a);
}
예제 #23
0
파일: clone.c 프로젝트: RsrchBoy/p5-Git-Raw
void test_online_clone__clone_mirror(void)
{
	git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
	git_reference *head;

	bool fetch_progress_cb_was_called = false;

	opts.fetch_opts.callbacks.transfer_progress = &fetch_progress;
	opts.fetch_opts.callbacks.payload = &fetch_progress_cb_was_called;

	opts.bare = true;
	opts.remote_cb = remote_mirror_cb;

	cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo.git", &opts));

	cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
	cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
	cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));

	cl_assert_equal_i(true, fetch_progress_cb_was_called);

	git_reference_free(head);
	git_repository_free(g_repo);
	g_repo = NULL;

	cl_fixture_cleanup("./foo.git");
}
예제 #24
0
파일: local.c 프로젝트: rlugojr/libgit2
void test_network_remote_local__push_delete(void)
{
    git_repository *src_repo;
    git_repository *dst_repo;
    git_remote *remote;
    git_reference *ref;
    char *spec_push[] = { "refs/heads/master" };
    char *spec_delete[] = { ":refs/heads/master" };
    git_strarray specs = {
        spec_push,
        1,
    };

    src_repo = cl_git_sandbox_init("testrepo.git");
    cl_git_pass(git_repository_init(&dst_repo, "target.git", 1));

    cl_git_pass(git_remote_create(&remote, src_repo, "origin", "./target.git"));

    /* Push the master branch and verify it's there */
    cl_git_pass(git_remote_push(remote, &specs, NULL));
    cl_git_pass(git_reference_lookup(&ref, dst_repo, "refs/heads/master"));
    git_reference_free(ref);

    specs.strings = spec_delete;
    cl_git_pass(git_remote_push(remote, &specs, NULL));
    cl_git_fail(git_reference_lookup(&ref, dst_repo, "refs/heads/master"));

    git_remote_free(remote);
    git_repository_free(dst_repo);
    cl_fixture_cleanup("target.git");
    cl_git_sandbox_cleanup();
}
예제 #25
0
파일: empty.c 프로젝트: 0CV0/libgit2
static void cleanup_repository(void *path)
{
	cl_fixture_cleanup((const char *)path);

	git_repository_free(g_repo_cloned);
	g_repo_cloned = NULL;
}
예제 #26
0
파일: racy.c 프로젝트: ethomson/libgit2
void test_index_racy__cleanup(void)
{
	git_repository_free(g_repo);
	g_repo = NULL;

	cl_fixture_cleanup("diff_racy");
}
예제 #27
0
/**
 * Cleanup
 *
 * This will be called once after each test finishes, even
 * if the test failed
 */
void test_status_worktree__cleanup(void)
{
	git_repository_free(_repository);
	_repository = NULL;

	cl_fixture_cleanup("status");
}
예제 #28
0
파일: fetch.c 프로젝트: DaneTheory/libgit2
void test_online_fetch__cleanup(void)
{
	git_repository_free(_repo);
	_repo = NULL;

	cl_fixture_cleanup("./fetch");
}
예제 #29
0
void test_config_validkeyname__cleanup(void)
{
	git_config_free(cfg);
	cfg = NULL;

	cl_fixture_cleanup("config10");
}
예제 #30
0
void test_network_fetchlocal__clone_into_mirror(void)
{
	git_buf path = GIT_BUF_INIT;
	git_repository *repo;
	git_remote *remote;
	git_reference *head;

	cl_git_pass(git_repository_init(&repo, "./foo.git", true));
	cl_git_pass(git_remote_create(&remote, repo, "origin", cl_git_fixture_url("testrepo.git")));

	git_remote_clear_refspecs(remote);
	cl_git_pass(git_remote_add_fetch(remote, "+refs/*:refs/*"));

	cl_git_pass(git_clone_into(repo, remote, NULL, NULL, NULL));

	cl_git_pass(git_reference_lookup(&head, repo, "HEAD"));
	cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
	cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head));

	git_remote_free(remote);
	git_reference_free(head);
	git_repository_free(repo);
	git_buf_free(&path);
	cl_fixture_cleanup("./foo.git");
}