Unverified Commit c587d806 by Patrick Steinhardt Committed by GitHub

Merge pull request #4613 from pks-t/pks/local-fetch-symrefs

transports: local: fix assert when fetching into repo with symrefs
parents 0eca4230 6c55fbf3
......@@ -510,8 +510,12 @@ static int local_counting(int stage, unsigned int current, unsigned int total, v
static int foreach_reference_cb(git_reference *reference, void *payload)
{
git_revwalk *walk = (git_revwalk *)payload;
int error;
if (git_reference_type(reference) != GIT_REF_OID)
return 0;
int error = git_revwalk_hide(walk, git_reference_target(reference));
error = git_revwalk_hide(walk, git_reference_target(reference));
/* The reference is in the local repository, so the target may not
* exist on the remote. It also may not be a commit. */
if (error == GIT_ENOTFOUND || error == GITERR_INVALID) {
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment