summaryrefslogtreecommitdiff
path: root/ref-filter.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-11-18 23:21:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-11-18 23:21:12 (GMT)
commit84679d470d577bcde1b6aa6af36c08a2d77b6e68 (patch)
treea42f20ac63cfacfcff3a25256592f41c22745961 /ref-filter.c
parent0b65a8dbdb38962e700ee16776a3042beb489060 (diff)
downloadgit-84679d470d577bcde1b6aa6af36c08a2d77b6e68.zip
git-84679d470d577bcde1b6aa6af36c08a2d77b6e68.tar.gz
git-84679d470d577bcde1b6aa6af36c08a2d77b6e68.tar.bz2
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>
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ref-filter.c b/ref-filter.c
index bc551a7..d7e91a7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -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 = " ";