summaryrefslogtreecommitdiff
path: root/t/t2018-checkout-branch.sh
diff options
context:
space:
mode:
authorLibravatar Tay Ray Chuan <rctay89@gmail.com>2010-08-10 00:52:26 +0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-08-09 12:57:17 -0700
commitcc70148385d5a36682d3b67fdaa726590577f257 (patch)
tree68f573fe1939b6b06031624c12dfdbf2553d72cd /t/t2018-checkout-branch.sh
parentbuiltin/checkout: learn -B (diff)
downloadtgif-cc70148385d5a36682d3b67fdaa726590577f257.tar.xz
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 't/t2018-checkout-branch.sh')
-rwxr-xr-xt/t2018-checkout-branch.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
index 1caffeac07..fa69016381 100755
--- a/t/t2018-checkout-branch.sh
+++ b/t/t2018-checkout-branch.sh
@@ -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 &&