Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,13 @@ static int remove_dir_recurse(struct strbuf *path, int flag, int *kept_up)
return 0;
}

if (is_mount_point(path)) {
/* Do not descend and nuke a mount point or junction. */
if (kept_up)
*kept_up = 1;
return 0;
}

flag &= ~REMOVE_DIR_KEEP_TOPLEVEL;
dir = opendir(path->buf);
if (!dir) {
Expand Down
9 changes: 9 additions & 0 deletions t/t2403-worktree-move.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,13 @@ test_expect_success 'move worktree with relative path to absolute path' '
test_cmp expect .git/worktrees/absolute/gitdir
'

test_expect_success MINGW 'worktree remove does not traverse mount points' '
mkdir target &&
>target/dont-remove-me &&
git worktree add --detach wt-junction &&
cmd //c "mklink /j wt-junction\\mnt target" &&
git worktree remove --force wt-junction &&
test_path_is_file target/dont-remove-me
'

test_done
Loading