hooks: allow customizing where the hook directory is
[gitweb.git] / t / t2025-worktree-add.sh
index 369417498946fcebb901d8593bb584f3767b1e67..cbfa41ec61b9f893b4df441e0289a5313ccaf413 100755 (executable)
@@ -123,10 +123,10 @@ test_expect_success 'checkout from a bare repo without "add"' '
 test_expect_success 'checkout with grafts' '
        test_when_finished rm .git/info/grafts &&
        test_commit abc &&
-       SHA1=`git rev-parse HEAD` &&
+       SHA1=$(git rev-parse HEAD) &&
        test_commit def &&
        test_commit xyz &&
-       echo "`git rev-parse HEAD` $SHA1" >.git/info/grafts &&
+       echo "$(git rev-parse HEAD) $SHA1" >.git/info/grafts &&
        cat >expected <<-\EOF &&
        xyz
        abc
@@ -193,6 +193,21 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
        test_must_fail git worktree add -B poodle --detach bamboo master
 '
 
+test_expect_success '"add -B" fails if the branch is checked out' '
+       git rev-parse newmaster >before &&
+       test_must_fail git worktree add -B newmaster bamboo master &&
+       git rev-parse newmaster >after &&
+       test_cmp before after
+'
+
+test_expect_success 'add -B' '
+       git worktree add -B poodle bamboo2 master^ &&
+       git -C bamboo2 symbolic-ref HEAD >actual &&
+       echo refs/heads/poodle >expected &&
+       test_cmp expected actual &&
+       test_cmp_rev master^ poodle
+'
+
 test_expect_success 'local clone from linked checkout' '
        git clone --local here here-clone &&
        ( cd here-clone && git fsck )