worktree move: accept destination as directory
[gitweb.git] / t / t2028-worktree-move.sh
index 8298aaf97f706ea796a12614acafd19636aeaa70..deb486cd8e38a229217a752f47dc11a34984933c 100755 (executable)
@@ -59,4 +59,41 @@ test_expect_success 'unlock worktree twice' '
        test_path_is_missing .git/worktrees/source/locked
 '
 
+test_expect_success 'move non-worktree' '
+       mkdir abc &&
+       test_must_fail git worktree move abc def
+'
+
+test_expect_success 'move locked worktree' '
+       git worktree lock source &&
+       test_when_finished "git worktree unlock source" &&
+       test_must_fail git worktree move source destination
+'
+
+test_expect_success 'move worktree' '
+       toplevel="$(pwd)" &&
+       git worktree move source destination &&
+       test_path_is_missing source &&
+       git worktree list --porcelain | grep "^worktree.*/destination" &&
+       ! git worktree list --porcelain | grep "^worktree.*/source" >empty &&
+       git -C destination log --format=%s >actual2 &&
+       echo init >expected2 &&
+       test_cmp expected2 actual2
+'
+
+test_expect_success 'move main worktree' '
+       test_must_fail git worktree move . def
+'
+
+test_expect_success 'move worktree to another dir' '
+       toplevel="$(pwd)" &&
+       mkdir some-dir &&
+       git worktree move destination some-dir &&
+       test_path_is_missing source &&
+       git worktree list --porcelain | grep "^worktree.*/some-dir/destination" &&
+       git -C some-dir/destination log --format=%s >actual2 &&
+       echo init >expected2 &&
+       test_cmp expected2 actual2
+'
+
 test_done