diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-06-20 11:01:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-20 11:01:02 -0700 |
commit | 6d41eb685a709b405ba0119453aaad3ad3888b7c (patch) | |
tree | ee256b65976d8f27492500356b6a38aa3f57dd28 /t | |
parent | Merge branch 'et/pretty-format-c-auto' (diff) | |
parent | worktree: allow "-" short-hand for @{-1} in add command (diff) | |
download | tgif-6d41eb685a709b405ba0119453aaad3ad3888b7c.tar.xz |
Merge branch 'jg/dash-is-last-branch-in-worktree-add'
"git worktree add" learned that '-' can be used as a short-hand for
"@{-1}", the previous branch.
* jg/dash-is-last-branch-in-worktree-add:
worktree: allow "-" short-hand for @{-1} in add command
Diffstat (limited to 't')
-rwxr-xr-x | t/t2025-worktree-add.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh index 3a22fc55fc..4bcc335a19 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 && |