diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-02-12 16:49:36 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-12 13:13:35 -0800 |
commit | 9f792bb4721066ce27ee98c4ad38d6d146b64fcf (patch) | |
tree | 503b7967b302c7b804cc4a89c6a671849b295910 /t | |
parent | worktree.c: add update_worktree_location() (diff) | |
download | tgif-9f792bb4721066ce27ee98c4ad38d6d146b64fcf.tar.xz |
worktree move: new command
This command allows to relocate linked worktrees. Main worktree cannot
(yet) be moved.
There are two options to move the main worktree, but both have
complications, so it's not implemented yet. Anyway the options are:
- convert the main worktree to a linked one and move it away, leave
the git repository where it is. The repo essentially becomes bare
after this move.
- move the repository with the main worktree. The tricky part is make
sure all file descriptors to the repository are closed, or it may
fail on Windows.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t2028-worktree-move.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh index 8298aaf97f..0f8abc0854 100755 --- a/t/t2028-worktree-move.sh +++ b/t/t2028-worktree-move.sh @@ -59,4 +59,30 @@ 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_done |