Merge branch 'rs/xdiff-hunk-with-func-line'
[gitweb.git] / t / t2025-worktree-add.sh
index da54327f5da14d4778ad8603a34b22cf96f96e5c..4bcc335a19f9d7864560945ed0f430728d0f1986 100755 (executable)
@@ -20,6 +20,22 @@ test_expect_success '"add" an existing empty worktree' '
        git worktree add --detach existing_empty master
 '
 
+test_expect_success '"add" using shorthand - fails when no previous branch' '
+       test_must_fail git worktree add existing_short -
+'
+
+test_expect_success '"add" using - shorthand' '
+       git checkout -b newbranch &&
+       echo hello >myworld &&
+       git add myworld &&
+       git commit -m myworld &&
+       git checkout master &&
+       git worktree add short-hand - &&
+       echo refs/heads/newbranch >expect &&
+       git -C short-hand rev-parse --symbolic-full-name HEAD >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success '"add" refuses to checkout locked branch' '
        test_must_fail git worktree add zere master &&
        ! test -d zere &&
@@ -254,6 +270,10 @@ test_expect_success 'not allow to delete a branch under rebase' '
        )
 '
 
+test_expect_success 'rename a branch under rebase not allowed' '
+       test_must_fail git branch -M under-rebase rebase-with-new-name
+'
+
 test_expect_success 'check out from current worktree branch ok' '
        (
                cd under-rebase &&
@@ -263,4 +283,21 @@ test_expect_success 'check out from current worktree branch ok' '
        )
 '
 
+test_expect_success 'checkout a branch under bisect' '
+       git worktree add under-bisect &&
+       (
+               cd under-bisect &&
+               git bisect start &&
+               git bisect bad &&
+               git bisect good HEAD~2 &&
+               git worktree list | grep "under-bisect.*detached HEAD" &&
+               test_must_fail git worktree add new-bisect under-bisect &&
+               ! test -d new-bisect
+       )
+'
+
+test_expect_success 'rename a branch under bisect not allowed' '
+       test_must_fail git branch -M under-bisect bisect-with-new-name
+'
+
 test_done