diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-04-06 10:39:16 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-04-06 11:33:36 +0100 |
commit | 6c55fbf37f0548fef0d5d0cdf3eefee26d8a6c04 (patch) | |
tree | 74352db945f77ce04f0dde2f213037597f0db7cf /src/transports/local.c | |
parent | 0eca42304a10c9ad6170a38a440dfab8e354d38d (diff) | |
download | libgit2-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 'src/transports/local.c')
-rw-r--r-- | src/transports/local.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index 740cf36a9..0178407e4 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -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) { |