Code

rebase: fix "rebase --continue" breakage
[git.git] / t / t7201-co.sh
index 867bbd26cbbacbe03ef76cadb6ff34976c324da5..55558aba8b862b93cb8ad97a681a4749bae3b3e1 100755 (executable)
@@ -3,7 +3,20 @@
 # Copyright (c) 2006 Junio C Hamano
 #
 
-test_description='git-checkout tests.'
+test_description='git-checkout tests.
+
+Creates master, forks renamer and side branches from it.
+Test switching across them.
+
+  ! [master] Initial A one, A two
+   * [renamer] Renamer R one->uno, M two
+    ! [side] Side M one, D two, A three
+  ---
+    + [side] Side M one, D two, A three
+   *  [renamer] Renamer R one->uno, M two
+  +*+ [master] Initial A one, A two
+
+'
 
 . ./test-lib.sh
 
@@ -64,7 +77,7 @@ test_expect_success "checkout with dirty tree without -m" '
 test_expect_success "checkout -m with dirty tree" '
 
        git checkout -f master &&
-       git clean &&
+       git clean -f &&
 
        fill 0 1 2 3 4 5 6 7 8 >one &&
        git checkout -m side &&
@@ -86,7 +99,7 @@ test_expect_success "checkout -m with dirty tree" '
 
 test_expect_success "checkout -m with dirty tree, renamed" '
 
-       git checkout -f master && git clean &&
+       git checkout -f master && git clean -f &&
 
        fill 1 2 3 4 5 7 8 >one &&
        if git checkout renamer
@@ -108,7 +121,7 @@ test_expect_success "checkout -m with dirty tree, renamed" '
 
 test_expect_success 'checkout -m with merge conflict' '
 
-       git checkout -f master && git clean &&
+       git checkout -f master && git clean -f &&
 
        fill 1 T 3 4 5 6 S 8 >one &&
        if git checkout renamer
@@ -129,4 +142,92 @@ test_expect_success 'checkout -m with merge conflict' '
        ! test -s current
 '
 
+test_expect_success 'checkout to detach HEAD' '
+
+       git checkout -f renamer && git clean -f &&
+       git checkout renamer^ &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       if git symbolic-ref HEAD >/dev/null 2>&1
+       then
+               echo "OOPS, HEAD is still symbolic???"
+               false
+       else
+               : happy
+       fi
+'
+
+test_expect_success 'checkout to detach HEAD with branchname^' '
+
+       git checkout -f master && git clean -f &&
+       git checkout renamer^ &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       if git symbolic-ref HEAD >/dev/null 2>&1
+       then
+               echo "OOPS, HEAD is still symbolic???"
+               false
+       else
+               : happy
+       fi
+'
+
+test_expect_success 'checkout to detach HEAD with HEAD^0' '
+
+       git checkout -f master && git clean -f &&
+       git checkout HEAD^0 &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       if git symbolic-ref HEAD >/dev/null 2>&1
+       then
+               echo "OOPS, HEAD is still symbolic???"
+               false
+       else
+               : happy
+       fi
+'
+
+test_expect_success 'checkout with ambiguous tag/branch names' '
+
+       git tag both side &&
+       git branch both master &&
+       git reset --hard &&
+       git checkout master &&
+
+       git checkout both &&
+       H=$(git rev-parse --verify HEAD) &&
+       M=$(git show-ref -s --verify refs/heads/master) &&
+       test "z$H" = "z$M" &&
+       name=$(git symbolic-ref HEAD 2>/dev/null) &&
+       test "z$name" = zrefs/heads/both
+
+'
+
+test_expect_success 'checkout with ambiguous tag/branch names' '
+
+       git reset --hard &&
+       git checkout master &&
+
+       git tag frotz side &&
+       git branch frotz master &&
+       git reset --hard &&
+       git checkout master &&
+
+       git checkout tags/frotz &&
+       H=$(git rev-parse --verify HEAD) &&
+       S=$(git show-ref -s --verify refs/heads/side) &&
+       test "z$H" = "z$S" &&
+       if name=$(git symbolic-ref HEAD 2>/dev/null)
+       then
+               echo "Bad -- should have detached"
+               false
+       else
+               : happy
+       fi
+
+'
+
 test_done