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:
parent
8d530c4d64
commit
7cd17e8057
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user