]> git.proxmox.com Git - libgit2.git/commitdiff
clone: add failing test for a mirror-clone with clone_into
authorCarlos Martín Nieto <cmn@dwim.me>
Thu, 15 May 2014 07:03:30 +0000 (09:03 +0200)
committerCarlos Martín Nieto <cmn@dwim.me>
Mon, 19 May 2014 12:24:43 +0000 (14:24 +0200)
Show a failure to perform a mirror-clone from a repository, both local
and remote.

tests/network/fetchlocal.c
tests/online/clone.c

index 4c39394bbc8e60638182137e2fe0523fc7bf1573..0d23bef48971f87c5b7695cd4b2fac6a2958737b 100644 (file)
@@ -86,3 +86,29 @@ void test_network_fetchlocal__partial(void)
        git_strarray_free(&refnames);
        git_remote_free(origin);
 }
+
+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");
+}
index 6e0e6395056300f9e2cba5755e4a01722bd9a04e..e269771c0b6402d7a3f705e072ca94e577e169fc 100644 (file)
@@ -164,6 +164,39 @@ void test_online_clone__clone_into(void)
        git_buf_free(&path);
 }
 
+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);
+       cl_fixture_cleanup("./foo.git");
+}
+
 static int update_tips(const char *refname, const git_oid *a, const git_oid *b, void *payload)
 {
        int *callcount = (int*)payload;