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

Touch up symlink .gitattributes support #2091

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

dscho
Copy link
Member

@dscho dscho commented Feb 24, 2019

In git.git's master, the git_check_attr() function already reflects the fact that it relies on the presence of a Git index: the git_check_attr() function takes an explicit index parameter, in preparation for some future in which multiple submodules can be processed in the same process (i.e. with multiple Git indexes).

To reflect that in our .gitattributes support for symbolic link types, let's redo a part of those patches: instead of hacking into symlink(), we implement and use an index-aware function that creates symbolic links.

Since `git_check_attr()` implicitly depends on the index, we really
should redo this in a manner that has a chance of going into upstream:
by introducing an index-aware helper function to create symbolic links,
and to override that in a Windows-specific manner instead.

In preparation for this, let's drop the original commit for now.

Signed-off-by: Johannes Schindelin <[email protected]>
On Windows, symbolic links actually have a type depending on the target:
it can be a file or a directory.

In certain circumstances, this poses problems, e.g. when a symbolic link
is supposed to point into a submodule that is not checked out, so there
is no way for Git to auto-detect the type.

To help with that, we will add support over the course of the next
commits to specify that symlink type via the Git attributes. This
requires an index_state, though, something that Git for Windows'
`symlink()` replacement cannot know about because the function signature
is defined by the POSIX standard and not ours to change.

So let's introduce a helper function to create symbolic links that
*does* know about the index_state.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho requested a review from drizzd February 24, 2019 21:39
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. Two minor comments.

Would you like me to test as well?

compat/mingw.c Outdated Show resolved Hide resolved
compat/mingw.c 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]>
Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Member Author

dscho commented Feb 25, 2019

Thank you for the review, @drizzd!

Would you like me to test as well?

That would be nice ;-)

@dscho
Copy link
Member Author

dscho commented Feb 26, 2019

I tested lightly, and everything seems to work as intended, still!

@dscho dscho merged commit 2481c4c into git-for-windows:master Feb 26, 2019
@dscho dscho deleted the symlink-attr-extra branch February 26, 2019 16:13
@dscho dscho added this to the v2.21.0 milestone Feb 26, 2019
dscho added a commit to dscho/git that referenced this pull request May 13, 2019
dscho added a commit to dscho/git that referenced this pull request May 13, 2019
git-for-windows-ci pushed a commit that referenced this pull request May 14, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request May 14, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request May 14, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request May 14, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request May 19, 2019
Touch up symlink .gitattributes support
dscho added a commit to dscho/git that referenced this pull request May 19, 2019
dscho added a commit that referenced this pull request May 19, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 8, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 8, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 8, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 9, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 9, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 9, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 12, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 14, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 14, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 16, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request Aug 22, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Aug 23, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Sep 2, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request Sep 24, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Sep 30, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request Oct 2, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Oct 7, 2019
Touch up symlink .gitattributes support
git-for-windows-ci pushed a commit that referenced this pull request Oct 17, 2019
Touch up symlink .gitattributes support
dscho added a commit that referenced this pull request Oct 21, 2019
Touch up symlink .gitattributes support
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