for-each-ref: do not segv with %(HEAD) on an unborn branch
The code to flip between "*" and " " prefixes depending on what branch is checked out used in --format='%(HEAD)' did not consider that HEAD may resolve to an unborn branch and dereferenced a NULL. This will become a lot easier to trigger as the codepath will be used to reimplement "git branch [--list]" in the future. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -1017,7 +1017,7 @@ static void populate_value(struct ref_array_item *ref)
|
||||
|
||||
head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
|
||||
sha1, NULL);
|
||||
if (!strcmp(ref->refname, head))
|
||||
if (head && !strcmp(ref->refname, head))
|
||||
v->s = "*";
|
||||
else
|
||||
v->s = " ";
|
||||
|
Reference in New Issue
Block a user