1
0
mirror of https://github.com/git/git synced 2024-07-05 00:58:49 +00:00

show-branch: avoid segfault with --reflog of unborn branch

When no branch is given to the "--reflog" option, we resolve
HEAD to get the default branch. However, if HEAD points to
an unborn branch, resolve_ref returns NULL, and we later
segfault trying to access it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2015-09-24 17:02:54 -04:00 committed by Junio C Hamano
parent 8d530c4d64
commit 7cd17e8057

View File

@ -743,6 +743,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
fake_av[1] = NULL;
av = fake_av;
ac = 1;
if (!*av)
die("no branches given, and HEAD is not valid");
}
if (ac != 1)
die("--reflog option needs one branch name");