Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid traversing NTFS junction points in git clean -dfx #2268

Merged
merged 5 commits into from
Jul 23, 2019

Conversation

drizzd
Copy link

@drizzd drizzd commented Jul 20, 2019

This addresses #607.

Based on #1976.

Copy link
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.

I left a couple of comments, and I'd really like to see this rebased so that the merge commit in this PR is no longer necessary.

path.c Show resolved Hide resolved
path.c Show resolved Hide resolved
compat/mingw.h Show resolved Hide resolved
compat/mingw.h Outdated Show resolved Hide resolved
@dscho
Copy link
Member

dscho commented Jul 22, 2019

@drizzd thank you!

@drizzd drizzd force-pushed the dont-clean-junctions branch 2 times, most recently from ba5039e to 34a1bd4 Compare July 23, 2019 15:49
dscho added 5 commits July 23, 2019 18:09
It seems to be not exactly rare on Windows to install NTFS junction
points (the equivalent of "bind mounts" on Linux/Unix) in worktrees,
e.g. to map some development tools into a subdirectory.

In such a scenario, it is pretty horrible if `git clean -dfx` traverses
into the mapped directory and starts to "clean up".

Let's just not do that. Let's make sure before we traverse into a
directory that it is not a mount point (or junction).

This addresses git-for-windows#607

Signed-off-by: Johannes Schindelin <[email protected]>
Windows' equivalent to "bind mounts", NTFS junction points, can be
unlinked without affecting the mount target. This is clearly what users
expect to happen when they call `git clean -dfx` in a worktree that
contains NTFS junction points: the junction should be removed, and the
target directory of said junction should be left alone (unless it is
inside the worktree).

Signed-off-by: Johannes Schindelin <[email protected]>
We will use this in the next commit to implement an FSCache-aware
version of is_mount_point().

Signed-off-by: Johannes Schindelin <[email protected]>
When FSCache is active, we can cache the reparse tag and use it directly
to determine whether a path refers to an NTFS junction, without any
additional, costly I/O.

Note: this change only makes a difference with the next commit, which
will make use of the FSCache in `git clean` (contingent on
`core.fscache` set, of course).

Signed-off-by: Johannes Schindelin <[email protected]>
The `git clean` command needs to enumerate plenty of files and
directories, and can therefore benefit from the FSCache.

Signed-off-by: Johannes Schindelin <[email protected]>
@drizzd drizzd force-pushed the dont-clean-junctions branch from 34a1bd4 to b7ca314 Compare July 23, 2019 16:31
@drizzd
Copy link
Author

drizzd commented Jul 23, 2019

Thanks for your comments. It's done.

@dscho dscho merged commit 32a748d into git-for-windows:master Jul 23, 2019
@dscho
Copy link
Member

dscho commented Jul 23, 2019

Thank you so much, @drizzd!

@dscho dscho added this to the v2.22.0(2) milestone Jul 23, 2019
git-for-windows-ci pushed a commit that referenced this pull request Jul 23, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Jul 23, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
dscho added a commit to git-for-windows/build-extra that referenced this pull request Jul 23, 2019
`git clean -dfx` [no longer follows NTFS junction points (also known
as mount points)](git-for-windows/git#2268).

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this pull request Jul 23, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Jul 23, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Jul 25, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Jul 25, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 14, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 14, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 16, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
dscho added a commit that referenced this pull request Aug 22, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Aug 23, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Sep 2, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
dscho added a commit that referenced this pull request Sep 24, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Sep 30, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
dscho added a commit that referenced this pull request Oct 2, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Oct 7, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
git-for-windows-ci pushed a commit that referenced this pull request Oct 17, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
dscho added a commit that referenced this pull request Oct 21, 2019
Avoid traversing NTFS junction points in `git clean -dfx`
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