mirror of
https://github.com/git/git.git
synced 2026-08-06 16:12:01 +00:00
Merge branch 'af/clone-revision-v0-segfault-fix'
A segfault when 'git clone --revision' talks to a server that does not support protocol v2 (falling back to protocol v0) has been corrected. * af/clone-revision-v0-segfault-fix: builtin/clone: fix segfault when using --revision with protocol v0
This commit is contained in:
@@ -557,7 +557,7 @@ static void update_remote_refs(const struct ref *refs,
|
||||
write_followtags(refs, msg);
|
||||
}
|
||||
|
||||
if (remote_head_points_at && !option_bare) {
|
||||
if (remote_head_points_at && remote_head_points_at->peer_ref && !option_bare) {
|
||||
struct strbuf head_ref = STRBUF_INIT;
|
||||
strbuf_addstr(&head_ref, branch_top);
|
||||
strbuf_addstr(&head_ref, "HEAD");
|
||||
|
||||
@@ -90,6 +90,14 @@ test_expect_success 'clone with --revision and --bare' '
|
||||
test_must_fail git -C dst config remote.origin.fetch
|
||||
'
|
||||
|
||||
test_expect_success 'clone with --revision and protocol v0' '
|
||||
test_when_finished "rm -rf dst" &&
|
||||
git -c protocol.version=0 clone --no-local --revision=refs/heads/main . dst &&
|
||||
git rev-parse refs/heads/main >expect &&
|
||||
git -C dst rev-parse HEAD >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'clone with --revision being a short raw commit hash' '
|
||||
test_when_finished "rm -rf dst" &&
|
||||
oid=$(git rev-parse --short refs/heads/feature) &&
|
||||
|
||||
Reference in New Issue
Block a user