summaryrefslogtreecommitdiff
path: root/t/t2025-worktree-add.sh
diff options
context:
space:
mode:
authorJordan DE GEA <jordan.de-gea@grenoble-inp.org>2016-05-27 13:17:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-05-31 19:28:25 (GMT)
commit1a450e2fd1f82311b214851d5b097b74c8fb0ade (patch)
treef06a2ef566d95a336e854212c7ad41aed2f7912d /t/t2025-worktree-add.sh
parentf3913c2d03abc660140678a9e14dac399f847647 (diff)
downloadgit-1a450e2fd1f82311b214851d5b097b74c8fb0ade.zip
git-1a450e2fd1f82311b214851d5b097b74c8fb0ade.tar.gz
git-1a450e2fd1f82311b214851d5b097b74c8fb0ade.tar.bz2
worktree: allow "-" short-hand for @{-1} in add command
Since `git worktree add` uses `git checkout` when `[<branch>]` is used, and `git checkout -` is already supported, it makes sense to allow the same shortcut in `git worktree add`. Signed-off-by: Jordan DE GEA <jordan.de-gea@grenoble-inp.org> Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2025-worktree-add.sh')
-rwxr-xr-xt/t2025-worktree-add.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 3a22fc5..4bcc335 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -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 &&