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>
This commit is contained in:

committed by
Junio C Hamano

parent
02ac98374e
commit
cc70148385
2
branch.c
2
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user