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

Handle git add <file> where <file> traverses an NTFS junction #2504

Merged
merged 3 commits into from
Feb 1, 2020

Conversation

dscho
Copy link
Member

@dscho dscho commented Jan 31, 2020

This is intended to fix #2481

dscho added 2 commits January 31, 2020 12:58
NTFS junctions are somewhat similar in spirit to Unix bind mounts: they
point to a different directory and are resolved by the filesystem
driver. As such, they appear to `lstat()` as if they are directories,
not as if they are symbolic links.

_Any_ user can create junctions, while symbolic links can only be
created by non-administrators in Developer Mode on Windows 10. Hence
NTFS junctions are much more common "in the wild" than NTFS symbolic
links.

It was reported in git-for-windows#2481
that adding files via an absolute path that traverses an NTFS junction:
since 1e64d18 (mingw: do resolve symlinks in `getcwd()`), we resolve not
only symbolic links but also NTFS junctions when determining the
absolute path of the current directory. The same is not true for `git
add <file>`, where symbolic links are resolved in `<file>`, but not NTFS
junctions.

Signed-off-by: Johannes Schindelin <[email protected]>
Some platforms (e.g. Windows) provide API functions to resolve paths
much quicker. Let's offer a way to short-cut `strbuf_realpath()` on
those platforms.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho added this to the Next release milestone Jan 31, 2020
There is a Win32 API function to resolve symbolic links, and we can use
that instead of resolving them manually. Even better, this function also
resolves NTFS junction points (which are somewhat similar to bind
mounts).

This fixes git-for-windows#2481.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho force-pushed the access-repo-via-junction branch from 4e017d2 to 100d194 Compare January 31, 2020 15:36
@dscho dscho requested review from drizzd, kgybels and orgads January 31, 2020 21:14
Copy link

@drizzd drizzd left a comment

Choose a reason for hiding this comment

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

Looks good to me

@dscho dscho merged commit 89a5bbf into git-for-windows:master Feb 1, 2020
@dscho dscho deleted the access-repo-via-junction branch February 1, 2020 11:13
@dscho
Copy link
Member Author

dscho commented Feb 1, 2020

Thanks @drizzd!

git-for-windows-ci pushed a commit that referenced this pull request Feb 1, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 1, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 1, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 1, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 5, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 5, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 5, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 6, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 10, 2020
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
@dscho dscho mentioned this pull request Jan 7, 2025
dscho added a commit to dscho/git that referenced this pull request Jan 7, 2025
…nction

Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit to dscho/git that referenced this pull request Jan 7, 2025
…nction

Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 9, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 9, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Jan 17, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Jan 27, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Jan 27, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Jan 27, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Jan 27, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 27, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 28, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Jan 28, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 3, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 5, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 5, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 5, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 5, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 6, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit that referenced this pull request Feb 6, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
git-for-windows-ci pushed a commit that referenced this pull request Feb 6, 2025
Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit to dscho/git that referenced this pull request Feb 6, 2025
…nction

Handle `git add <file>` where <file> traverses an NTFS junction
dscho added a commit to dscho/git that referenced this pull request Feb 6, 2025
…nction

Handle `git add <file>` where <file> traverses an NTFS junction
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.

Git cannot stage full-path files if the path to the repository is a directory junction
2 participants