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
@ -124,6 +124,12 @@ test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
|
||||
do_checkout branch2 "" -B
|
||||
'
|
||||
|
||||
test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' '
|
||||
git checkout $(git rev-parse --verify HEAD) &&
|
||||
|
||||
do_checkout branch2 "" -B
|
||||
'
|
||||
|
||||
test_expect_success 'checkout -B to an existing branch with an explicit ref resets branch to that ref' '
|
||||
git checkout branch1 &&
|
||||
|
||||
|
Reference in New Issue
Block a user