Merge branch 'js/maint-add-path-stat-pwd'
[gitweb.git] / t / t2018-checkout-branch.sh
index 1caffeac074ed9a8e434a3d6e53c20b00e8672cc..a42e03967b1df3001df24089f2c50008c092ac51 100755 (executable)
@@ -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 &&
 
@@ -163,4 +169,15 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes
        test_must_fail test_dirty_mergeable
 '
 
+test_expect_success 'checkout -b <describe>' '
+       git tag -f -m "First commit" initial initial &&
+       git checkout -f change1 &&
+       name=$(git describe) &&
+       git checkout -b $name &&
+       git diff --exit-code change1 &&
+       echo "refs/heads/$name" >expect &&
+       git symbolic-ref HEAD >actual &&
+       test_cmp expect actual
+'
+
 test_done