Merge branch 'rs/t1002-do-not-use-sum' into next
[gitweb.git] / t / t2025-worktree-add.sh
index 3a22fc55fc324fbfbfdcdf39fb71e829c89729b5..b5c47ac602d65ebfb0f4baebc098f26d5d1a464c 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 &&
@@ -47,6 +63,12 @@ test_expect_success '"add" worktree' '
        )
 '
 
+test_expect_success '"add" worktree with lock' '
+       git rev-parse HEAD >expect &&
+       git worktree add --detach --lock here-with-lock master &&
+       test -f .git/worktrees/here-with-lock/locked
+'
+
 test_expect_success '"add" worktree from a subdir' '
        (
                mkdir sub &&
@@ -122,6 +144,14 @@ test_expect_success 'checkout from a bare repo without "add"' '
        )
 '
 
+test_expect_success '"add" default branch of a bare repo' '
+       (
+               git clone --bare . bare2 &&
+               cd bare2 &&
+               git worktree add ../there3 master
+       )
+'
+
 test_expect_success 'checkout with grafts' '
        test_when_finished rm .git/info/grafts &&
        test_commit abc &&