Skip to content

Fix creating native symlinks pointing to .. #101

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

Merged
merged 3 commits into from
Jun 23, 2025

Conversation

dscho
Copy link
Member

@dscho dscho commented Jun 19, 2025

Git's test suite currently does not pass under MSYS=winsymlinks:nativestrict. Most of those issues need to be addressed in Git, as they are either due to incorrect assumptions, or due to bugs in the symlink support code.

However, one of the issues is in a test that first creates a symlink pointing to .. and later verifies that following that symlink in cat-file works: Instead of creating a link to .., ln -s creates a link to ../../$(basename "$PWD"). This link still points to the same entity, but it is incorrect, and not due to a bug in Git, but due to a bug in the MSYS2 runtime.

This fixes t1006.311(git cat-file --batch-check --follow-symlinks works for .. links).

I contributed this fix to the Cygwin project here: https://inbox.sourceware.org/cygwin-patches/6058889e2ae8c9c827a8d6678f09b3b1741e2fcf.1750413578.git.johannes.schindelin@gmx.de/T/#u.

Blackhex and others added 2 commits June 11, 2025 08:36
(cherry picked from commit 2029784e05d9805aa074dcadb99c31311790b7ac)
When running

	CYGWIN=winsymlinks:nativestrict ln -s .. abc

the counter-intuitive result is _not_ a symbolic link to `..`, but
instead to `../../$(basename "$PWD")`.

The reason for this is that the search for the longest common prefix
assumes that the link target is not a strict prefix of the parent
directory of the link itself.

Let's fix that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho self-assigned this Jun 20, 2025
@dscho dscho changed the title Fix dotdot native symlink gfw Fix creating native symlinks pointing to .. Jun 20, 2025
@dscho dscho marked this pull request as ready for review June 20, 2025 12:27
@dscho
Copy link
Member Author

dscho commented Jun 23, 2025

/open pr

The workflow run was started

…ymlink-gfw

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Jun 23, 2025

/open pr

The workflow run was started

@dscho dscho merged commit d973094 into git-for-windows:main Jun 23, 2025
31 checks passed
@dscho dscho deleted the fix-dotdot-native_symlink-gfw branch June 23, 2025 17:59
@dscho dscho mentioned this pull request Jun 24, 2025
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.

[New msys2-runtime version] symlink_native: allow linking to ..
2 participants