builtin/clone: fix segfault when using --revision on some servers

Fix a segfault when a server advertises more refs than requested when using the --revision argument. Signed-off-by: Adrian Friedli <adrian.friedli@mt.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Adrian Friedli committed Jul 23, 2026 at 16:43 UTC 638dc3b063aea1dbf6ff03c4785cf9d19e0f49d3
1 file changed +1 -1
builtin/clone.c
+1 -1
@@ -557,7 +557,7 @@ static void update_remote_refs(const struct ref *refs,
557 write_followtags(refs, msg);
558 }
559
560 - if (remote_head_points_at && !option_bare) {
560 + if (remote_head_points_at && remote_head_points_at->peer_ref && !option_bare) {
561 struct strbuf head_ref = STRBUF_INIT;
562 strbuf_addstr(&head_ref, branch_top);
563 strbuf_addstr(&head_ref, "HEAD");