status: differentiate interactive from non-interactive rebases
[gitweb.git] / t / t2025-checkout-to.sh
index edd34049cf8aea5db097e65b3ce8ff8af4caf268..f8e4df4818523de74ff7330f015415bfb9cc8227 100755 (executable)
@@ -13,10 +13,21 @@ test_expect_success 'checkout --to not updating paths' '
 '
 
 test_expect_success 'checkout --to an existing worktree' '
-       mkdir existing &&
+       mkdir -p existing/subtree &&
        test_must_fail git checkout --detach --to existing master
 '
 
+test_expect_success 'checkout --to an existing empty worktree' '
+       mkdir existing_empty &&
+       git checkout --detach --to existing_empty master
+'
+
+test_expect_success 'checkout --to refuses to checkout locked branch' '
+       test_must_fail git checkout --to zere master &&
+       ! test -d zere &&
+       ! test -d .git/worktrees/zere
+'
+
 test_expect_success 'checkout --to a new worktree' '
        git rev-parse HEAD >expect &&
        git checkout --detach --to here master &&
@@ -68,6 +79,13 @@ test_expect_success 'die the same branch is already checked out' '
        )
 '
 
+test_expect_success 'not die the same branch is already checked out' '
+       (
+               cd here &&
+               git checkout --ignore-other-worktrees --to anothernewmaster newmaster
+       )
+'
+
 test_expect_success 'not die on re-checking out current branch' '
        (
                cd there &&
@@ -75,4 +93,37 @@ test_expect_success 'not die on re-checking out current branch' '
        )
 '
 
+test_expect_success 'checkout --to from a bare repo' '
+       (
+               git clone --bare . bare &&
+               cd bare &&
+               git checkout --to ../there2 -b bare-master master
+       )
+'
+
+test_expect_success 'checkout from a bare repo without --to' '
+       (
+               cd bare &&
+               test_must_fail git checkout master
+       )
+'
+
+test_expect_success 'checkout with grafts' '
+       test_when_finished rm .git/info/grafts &&
+       test_commit abc &&
+       SHA1=`git rev-parse HEAD` &&
+       test_commit def &&
+       test_commit xyz &&
+       echo "`git rev-parse HEAD` $SHA1" >.git/info/grafts &&
+       cat >expected <<-\EOF &&
+       xyz
+       abc
+       EOF
+       git log --format=%s -2 >actual &&
+       test_cmp expected actual &&
+       git checkout --detach --to grafted master &&
+       git --git-dir=grafted/.git log --format=%s -2 >actual &&
+       test_cmp expected actual
+'
+
 test_done