On Wed, Jan 24, 2018 at 4:53 AM, Nguyễn Thái Ngọc Duy [off-list ref] wrote:
quoted hunk ↗ jump to hunk
[...]
- $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.
[...]
Noticed-by: Kaartic Sivaraam [off-list ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh
@@ -116,4 +116,12 @@ test_expect_success 'force remove worktree with untracked file' '
+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
+'
Perhaps there could also be a test to verify that a missing but locked
worktree is _not_ removed?