summaryrefslogtreecommitdiff
path: root/tests/fetchhead
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-04-06 10:39:16 +0100
committerPatrick Steinhardt <ps@pks.im>2018-04-06 11:33:36 +0100
commit6c55fbf37f0548fef0d5d0cdf3eefee26d8a6c04 (patch)
tree74352db945f77ce04f0dde2f213037597f0db7cf /tests/fetchhead
parent0eca42304a10c9ad6170a38a440dfab8e354d38d (diff)
downloadlibgit2-6c55fbf37f0548fef0d5d0cdf3eefee26d8a6c04.tar.gz
transports: local: fix assert when fetching into repo with symrefs
When fetching into a repository which has symbolic references via the "local" transport we run into an assert. The assert is being triggered while we negotiate the packfile between the two repositories. When hiding known revisions from the packbuilder revwalk, we unconditionally hide all references of the local refdb. In case one of these references is a symbolic reference, though, this means we're trying to hide a `NULL` OID, which triggers the assert. Fix the issue by only hiding OID references from the revwalk. Add a test to catch this issue in the future.
Diffstat (limited to 'tests/fetchhead')
-rw-r--r--tests/fetchhead/nonetwork.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c
index 4dabb577e..a6394600a 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/fetchhead/nonetwork.c
@@ -343,6 +343,29 @@ void test_fetchhead_nonetwork__unborn_with_upstream(void)
cl_fixture_cleanup("./repowithunborn");
}
+void test_fetchhead_nonetwork__fetch_into_repo_with_symrefs(void)
+{
+ git_repository *repo;
+ git_remote *remote;
+ git_reference *symref;
+
+ repo = cl_git_sandbox_init("empty_standard_repo");
+
+ /*
+ * Testing for a specific constellation where the repository has at
+ * least one symbolic reference in its refdb.
+ */
+ cl_git_pass(git_reference_symbolic_create(&symref, repo, "refs/heads/symref", "refs/heads/master", 0, NULL));
+
+ cl_git_pass(git_remote_set_url(repo, "origin", cl_fixture("testrepo.git")));
+ cl_git_pass(git_remote_lookup(&remote, repo, "origin"));
+ cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
+
+ git_remote_free(remote);
+ git_reference_free(symref);
+ cl_git_sandbox_cleanup();
+}
+
void test_fetchhead_nonetwork__quote_in_branch_name(void)
{
cl_set_cleanup(&cleanup_repository, "./test1");