diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-05-23 14:38:18 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-23 14:38:18 +0900 |
commit | 10174da9f1643eb939d93d479547494baf77377b (patch) | |
tree | 7984b987bc20e55d21c26d83569eabb11928256d /t/t2025-worktree-add.sh | |
parent | Merge branch 'js/deprecate-grafts' (diff) | |
parent | worktree: teach "add" to check out existing branches (diff) | |
download | tgif-10174da9f1643eb939d93d479547494baf77377b.tar.xz |
Merge branch 'tg/worktree-add-existing-branch'
"git worktree add" learned to check out an existing branch.
* tg/worktree-add-existing-branch:
worktree: teach "add" to check out existing branches
worktree: factor out dwim_branch function
worktree: improve message when creating a new worktree
worktree: remove extra members from struct add_opts
Diffstat (limited to 't/t2025-worktree-add.sh')
-rwxr-xr-x | t/t2025-worktree-add.sh | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh index d0d2e4f7ec..2240498924 100755 --- a/t/t2025-worktree-add.sh +++ b/t/t2025-worktree-add.sh @@ -198,13 +198,25 @@ test_expect_success '"add" with <branch> omitted' ' test_cmp_rev HEAD bat ' -test_expect_success '"add" auto-vivify does not clobber existing branch' ' - test_commit c1 && - test_commit c2 && - git branch precious HEAD~1 && - test_must_fail git worktree add precious && - test_cmp_rev HEAD~1 precious && - test_path_is_missing precious +test_expect_success '"add" checks out existing branch of dwimd name' ' + git branch dwim HEAD~1 && + git worktree add dwim && + test_cmp_rev HEAD~1 dwim && + ( + cd dwim && + test_cmp_rev HEAD dwim + ) +' + +test_expect_success '"add <path>" dwim fails with checked out branch' ' + git checkout -b test-branch && + test_must_fail git worktree add test-branch && + test_path_is_missing test-branch +' + +test_expect_success '"add --force" with existing dwimd name doesnt die' ' + git checkout test-branch && + git worktree add --force test-branch ' test_expect_success '"add" no auto-vivify with --detach and <branch> omitted' ' |