Skip to content

Don't traverse mount points in remove_dir_recurse()#6151

Merged
dscho merged 1 commit intogit-for-windows:mainfrom
maks244:dir-do-not-traverse-mount-points
Mar 31, 2026
Merged

Don't traverse mount points in remove_dir_recurse()#6151
dscho merged 1 commit intogit-for-windows:mainfrom
maks244:dir-do-not-traverse-mount-points

Conversation

@maks244
Copy link
Copy Markdown

@maks244 maks244 commented Mar 30, 2026

remove_dir_recurse() in dir.c doesn't check for mount points, even though this check was already added for git clean in #2268. So git worktree remove (or anything else that calls it) will traverse NTFS junctions and delete whatever is there. Similar to #607.

This extends the same check from #2268 but for anything that calls remove_dir_recurse().

It was already decided in ef22148 (clean: do not traverse mount points,
2018-12-07) that we shouldn't traverse NTFS junctions/bind mounts when
using `git clean`, partly because they're sometimes used in worktrees.
But the same check wasn't applied to `remove_dir_recurse()` in `dir.c`,
which `git worktree remove` uses. So removing a worktree suffers the
same problem we had previously with `git clean`.

Let's add the same guard from ef22148.

Signed-off-by: Maks Kuznia <makskuznia244@gmail.com>
Copy link
Copy Markdown
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@dscho dscho added this to the Next release milestone Mar 31, 2026
@dscho dscho merged commit f549d3f into git-for-windows:main Mar 31, 2026
60 checks passed
@dscho
Copy link
Copy Markdown
Member

dscho commented Mar 31, 2026

/add relnote bug Similar to how git clean already avoids traversing NTFS junctions, git worktree remove now does the same.

The workflow run was started

github-actions bot pushed a commit to git-for-windows/build-extra that referenced this pull request Mar 31, 2026
Similar to how `git clean` already avoids traversing NTFS junctions,
`git worktree remove` [now does the
same](git-for-windows/git#6151).

Signed-off-by: gitforwindowshelper[bot] <gitforwindowshelper-bot@users.noreply.github.com>
gitforwindowshelper bot pushed a commit that referenced this pull request Apr 1, 2026
`remove_dir_recurse()` in `dir.c` doesn't check for mount points, even
though this check was already added for `git clean` in #2268. So `git
worktree remove` (or anything else that calls it) will traverse NTFS
junctions and delete whatever is there. Similar to #607.

This extends the same check from #2268 but for anything that calls
`remove_dir_recurse()`.
gitforwindowshelper bot pushed a commit to git-for-windows/shears-builds that referenced this pull request Apr 1, 2026
…s#6151)

`remove_dir_recurse()` in `dir.c` doesn't check for mount points, even
though this check was already added for `git clean` in git-for-windows#2268. So `git
worktree remove` (or anything else that calls it) will traverse NTFS
junctions and delete whatever is there. Similar to git-for-windows#607.

This extends the same check from git-for-windows#2268 but for anything that calls
`remove_dir_recurse()`.
gitforwindowshelper bot pushed a commit that referenced this pull request Apr 2, 2026
`remove_dir_recurse()` in `dir.c` doesn't check for mount points, even
though this check was already added for `git clean` in #2268. So `git
worktree remove` (or anything else that calls it) will traverse NTFS
junctions and delete whatever is there. Similar to #607.

This extends the same check from #2268 but for anything that calls
`remove_dir_recurse()`.
gitforwindowshelper bot pushed a commit to git-for-windows/shears-builds that referenced this pull request Apr 2, 2026
…s#6151)

`remove_dir_recurse()` in `dir.c` doesn't check for mount points, even
though this check was already added for `git clean` in git-for-windows#2268. So `git
worktree remove` (or anything else that calls it) will traverse NTFS
junctions and delete whatever is there. Similar to git-for-windows#607.

This extends the same check from git-for-windows#2268 but for anything that calls
`remove_dir_recurse()`.
gitforwindowshelper bot pushed a commit that referenced this pull request Apr 2, 2026
`remove_dir_recurse()` in `dir.c` doesn't check for mount points, even
though this check was already added for `git clean` in #2268. So `git
worktree remove` (or anything else that calls it) will traverse NTFS
junctions and delete whatever is there. Similar to #607.

This extends the same check from #2268 but for anything that calls
`remove_dir_recurse()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants