summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
authorTay Ray Chuan <rctay89@gmail.com>2010-08-10 00:52:26 +0800
committerJunio C Hamano <gitster@pobox.com>2010-08-09 12:57:17 -0700
commitcc70148385d5a36682d3b67fdaa726590577f257 (patch)
tree68f573fe1939b6b06031624c12dfdbf2553d72cd /branch.c
parent02ac98374eefbe4a46d4b53a8a78057ad8ad39b7 (diff)
downloadgit-cc70148385d5a36682d3b67fdaa726590577f257.tar.gz
builtin/checkout: handle -B from detached HEAD correctly
Ensure that strcmp() isn't called when head is null. Previously we were getting segfaults when checkout -B was done from a detached HEAD. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'branch.c')
-rw-r--r--branch.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/branch.c b/branch.c
index 2ab42aaf4d..93dc866f8c 100644
--- a/branch.c
+++ b/branch.c
@@ -159,7 +159,7 @@ void create_branch(const char *head,
dont_change_ref = 1;
else if (!force)
die("A branch named '%s' already exists.", name);
- else if (!is_bare_repository() && !strcmp(head, name))
+ else if (!is_bare_repository() && head && !strcmp(head, name))
die("Cannot force update the current branch.");
forcing = 1;
}