diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-02-12 16:49:40 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-12 13:13:35 -0800 |
commit | ee6763af0a3b97225803c6c908a29de40336cf38 (patch) | |
tree | 5345b7b1b711cec6a79f2f6a81e442423de2ee54 /t/t2028-worktree-move.sh | |
parent | worktree remove: new command (diff) | |
download | tgif-ee6763af0a3b97225803c6c908a29de40336cf38.tar.xz |
worktree remove: allow it when $GIT_WORK_TREE is already gone
"git worktree remove" basically consists of two things
- delete $GIT_WORK_TREE
- delete $GIT_DIR (which is $SUPER_GIT_DIR/worktrees/something)
If $GIT_WORK_TREE is already gone for some reason, we should be able
to finish the job by deleting $GIT_DIR.
Two notes:
- $GIT_WORK_TREE _can_ be missing if the worktree is locked. In that
case we must not delete $GIT_DIR because the real $GIT_WORK_TREE may
be in a usb stick somewhere. This is already handled because we
check for lock first.
- validate_worktree() is still called because it may do more checks in
future (and it already does something else, like checking main
worktree, but that's irrelevant in this case)
Noticed-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
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/t2028-worktree-move.sh')
-rwxr-xr-x | t/t2028-worktree-move.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh index 4718c4552f..082368d8c6 100755 --- a/t/t2028-worktree-move.sh +++ b/t/t2028-worktree-move.sh @@ -126,4 +126,21 @@ test_expect_success 'force remove worktree with untracked file' ' test_path_is_missing destination ' +test_expect_success 'remove missing worktree' ' + git worktree add to-be-gone && + test -d .git/worktrees/to-be-gone && + mv to-be-gone gone && + git worktree remove to-be-gone && + test_path_is_missing .git/worktrees/to-be-gone +' + +test_expect_success 'NOT remove missing-but-locked worktree' ' + git worktree add gone-but-locked && + git worktree lock gone-but-locked && + test -d .git/worktrees/gone-but-locked && + mv gone-but-locked really-gone-now && + test_must_fail git worktree remove gone-but-locked && + test_path_is_dir .git/worktrees/gone-but-locked +' + test_done |