cygporter / git

Cygwin Git packaging paraphernalia
2 stars 2 forks source link

Git cannot create Windows native symlinks #27

Open ghost opened 7 years ago

ghost commented 7 years ago

Cygwin can easily create Windows native symlinks:

touch alfa.txt
CYGWIN=winsymlinks:native ln -s alfa.txt bravo.txt

However Cygwin Git seems to have no way to create Windows native symlinks:

CYGWIN=winsymlinks:lnk git clone git://github.com/stedolan/jq

creates README as a Shortcut (.lnk) file.

CYGWIN=winsymlinks:native git clone git://github.com/stedolan/jq

creates README as a Cygwin symlink, not a Windows native symlink.

CYGWIN=winsymlinks:nativestrict git clone git://github.com/stedolan/jq

just creates a plain text file, not even a symlink:

$ cat jq/README
README.md

http://cygwin.com/ml/cygwin/2017-03/msg00110.html

ghost commented 7 years ago

@me-and any comment? I am also requesting new version:

http://cygwin.com/ml/cygwin/2017-04/msg00193.html

me-and commented 7 years ago

(I really need to get GitHub notifications working in a more reliable fashion; notifications about things I actually care about like this are far too often getting lost in the noise.)

It looks to me like the problem is Cygwin failing to create native symlinks. If you look at the CYGWIN environment variable documentation, if creating a symlink using winsymlinks:native fails, it'll fall back to creating Cygwin default symlinks, whereas if winsymlinks:nativestrict is set, it will fail to create the symlink entirely, which results in Git's default behaviour in environments without symlinks, i.e. setting core.symlinks to false and just recording the symlink destination in the file text.

Interestingly, I get the same behaviour with ln -s in Cygwin Bash on my current machine unless I'm running with Administrator privileges.

The next question, then, is working out why running ln -s from an elevated Cygwin Bash shell works, but the equivalent within Git doesn't. Next step there, I think, will be digging through strace output from a Git command that ought to create a Windows native symlink.

douglaswth commented 6 years ago

I just ran into this and noticed that if I delete a symlink and then use git checkout -f to restore it, it does come back as a Windows native symlink unlike the behavior from git clone.

ieglandDRS commented 5 years ago

This issue is causing lots of headaches for me over here.

ieglandDRS commented 5 years ago

This is a summary of what I found out about this issue: https://superuser.com/questions/1469330/why-cant-i-clone-a-git-repository-with-submodules-in-cygwin-using-windows-nativ/1469332