worktree: make add <path> <branch> dwim
[gitweb.git] / t / t2025-worktree-add.sh
index 72e8b629271dacb38f8c889537bbff858789519d..96ebc63d0451edae7e89a84b1fa6e0f0e356763e 100755 (executable)
@@ -365,4 +365,23 @@ test_expect_success '--no-track avoids setting up tracking' '
        )
 '
 
+test_expect_success '"add" <path> <non-existent-branch> fails' '
+       test_must_fail git worktree add foo non-existent
+'
+
+test_expect_success '"add" <path> <branch> dwims' '
+       test_when_finished rm -rf repo_upstream repo_dwim foo &&
+       setup_remote_repo repo_upstream repo_dwim &&
+       git init repo_dwim &&
+       (
+               cd repo_dwim &&
+               git worktree add ../foo foo
+       ) &&
+       (
+               cd foo &&
+               test_branch_upstream foo repo_upstream foo &&
+               test_cmp_rev refs/remotes/repo_upstream/foo refs/heads/foo
+       )
+'
+
 test_done