Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-25 00:02:54 +0300
committerJunio C Hamano <gitster@pobox.com>2015-09-25 20:18:18 +0300
commit7cd17e80579c2bffd6245837175a6e1b12a78045 (patch)
treea05065010e9c4d15c90c8896b133c5162e45e6dc /builtin/show-branch.c
parent8d530c4d64ffcc853889f7b385f554d53db375ed (diff)
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>
Diffstat (limited to 'builtin/show-branch.c')
-rw-r--r--builtin/show-branch.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 408ce70307..092b59b0b3 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -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");