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

Specify symlink type in .gitattributes #1897

Merged
merged 3 commits into from
Oct 31, 2018
Merged

Specify symlink type in .gitattributes #1897

merged 3 commits into from
Oct 31, 2018

Conversation

piscisaureus
Copy link

On Windows, symbolic links have a type: a "file symlink" must point at
a file, and a "directory symlink" must point at a directory. If the
type of symlink does not match its target, it doesn't work.

Git does not record the type of symlink in the index or in a tree. On
checkout it'll guess the type, which only works if the target exists
at the time the symlink is created. This may often not be the case,
for example when the link points at a directory inside a submodule.

By specifying symlink=file or symlink=dir the user can specify what
type of symlink Git should create, so Git doesn't have to rely on
unreliable heuristics.

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.

This looks pretty awesome already, and I like this idea of specifying the symlink type via the Git attributes! I offered a couple of suggestions how to change this, hopefully you agree that those are improvements?

compat/mingw.c Outdated Show resolved Hide resolved

# Tell MSYS to create native symlinks. Without this flag test-lib's
# prerequisite detection for SYMLINKS doesn't detect the right thing.
MSYS=winsymlinks:nativestrict && export MSYS

This comment was marked as off-topic.

t/t2040-checkout-symlink-attr.sh Outdated Show resolved Hide resolved
t/t2040-checkout-symlink-attr.sh Outdated Show resolved Hide resolved
t/t2040-checkout-symlink-attr.sh Outdated Show resolved Hide resolved
t/t2040-checkout-symlink-attr.sh Show resolved Hide resolved
On Windows, symbolic links have a type: a "file symlink" must point at
a file, and a "directory symlink" must point at a directory. If the
type of symlink does not match its target, it doesn't work.

Git does not record the type of symlink in the index or in a tree. On
checkout it'll guess the type, which only works if the target exists
at the time the symlink is created. This may often not be the case,
for example when the link points at a directory inside a submodule.

By specifying `symlink=file` or `symlink=dir` the user can specify what
type of symlink Git should create, so Git doesn't have to rely on
unreliable heuristics.

Signed-off-by: Bert Belder <[email protected]>
@piscisaureus
Copy link
Author

@dscho Thanks for the review. I've updated the patch, PTAL.

@dscho dscho merged commit 25a7f44 into git-for-windows:master Oct 31, 2018
@dscho
Copy link
Member

dscho commented Oct 31, 2018

Excellent. Thank you so much!

dscho added a commit to git-for-windows/build-extra that referenced this pull request Oct 31, 2018
The type of symlinks to create (directory
or file) [can now be specified via the
`.gitattributes`](git-for-windows/git#1897).

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho added this to the v2.19.1(2) milestone Oct 31, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 19, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 19, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 20, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 20, 2018
dscho added a commit that referenced this pull request Nov 21, 2018
Specify symlink type in .gitattributes
dscho added a commit that referenced this pull request Nov 21, 2018
Specify symlink type in .gitattributes
dscho added a commit to dscho/git that referenced this pull request Nov 23, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 23, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 30, 2018
dscho added a commit to dscho/git that referenced this pull request Nov 30, 2018
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 1, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 2, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 2, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 2, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 3, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 6, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 6, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Specify symlink type in .gitattributes
@dscho dscho mentioned this pull request Jan 7, 2025
dscho added a commit to dscho/git that referenced this pull request Jan 7, 2025
dscho added a commit to dscho/git that referenced this pull request Jan 7, 2025
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 8, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 9, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 9, 2025
Specify symlink type in .gitattributes
dscho added a commit that referenced this pull request Jan 17, 2025
Specify symlink type in .gitattributes
dscho added a commit that referenced this pull request Jan 27, 2025
Specify symlink type in .gitattributes
dscho added a commit that referenced this pull request Jan 27, 2025
Specify symlink type in .gitattributes
dscho added a commit that referenced this pull request Jan 27, 2025
Specify symlink type in .gitattributes
dscho added a commit that referenced this pull request Jan 27, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 27, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 28, 2025
Specify symlink type in .gitattributes
git-for-windows-ci pushed a commit that referenced this pull request Jan 28, 2025
Specify symlink type in .gitattributes
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.

3 participants