Bug 568955

Summary: Git clone or commit reports symlinks permanently as modified
Product: [Technology] EGit Reporter: Panos Kavalagios <Panos.Kavalagios>
Component: CoreAssignee: Project Inbox <egit.core-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: david.guerrero, twolf
Version: 5.9Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Panos Kavalagios CLA 2020-11-19 04:57:35 EST
When you commit a link created with mklink Windows command:

mklink dest source

The link is always reported as modified in the sync view. Re-committing the file does not help. If you set "core.symlinks=false" the file is stopped being reported as modified, but the link is not created during repo cloning as expected.

Both Windows and Cygwin Git command lines are working fine. They do not report the links as modified after cloning the repository. Only Eclipse eGit seems to have issue or at least missing some kind of configuration to overcome this issue.
Comment 1 Thomas Wolf CLA 2020-11-23 02:30:03 EST
Symlinks on Windows are a nuisance. See [1] for a summary.

JGit does not handle symlinks on Windows. It also does not implement the core.symlinks config from git-for-windows. There's several reasons for this:

* Historical: JGit was originally written in Java 6, which definitely could
  not do symlinks on Windows.
* Windows: symlinks may require the user to have special privileges that are
  not assigned by default.
* Java: I'm not sure the Java Files.createSymbolicLink() method does the right
  thing is all cases. It would have to create Junctions for symlinks pointing
  to directories.

If someone wants to try implementing symlink support for Windows in JGit: we welcome contributions. See [2] for guidance. Some hints to get started:

* Note that currently JGit assumes that a symlink is just a file containing
  the linked-to path, and that it can be read and written as such. This
  assumption probably doesn't hold on Windows. Maybe for file symlinks, but
  from what I've read about Junctions, it won't hold for those.
* The starting point would be FS_Win32.java. Subclass FS_Win32_Cygwin might
  also need to be adapted?

Most JGit and EGit maintainers work on Linux or OS X and thus don't have an incentive to implement this, nor do they have a development environment to do so.

[1] https://github.com/git-for-windows/git/wiki/Symbolic-Links
[2] https://wiki.eclipse.org/EGit/Contributor_Guide#Contributing_Patches
Comment 2 Thomas Wolf CLA 2020-11-23 03:06:19 EST
Another good overview of "symlinks" on Windows is https://www.joshkel.com/2018/01/18/symlinks-in-windows/ .
Comment 3 Panos Kavalagios CLA 2020-11-25 05:05:59 EST
Thanks for the explanations. That would be a nice feature to support windows links in future versions.

For the time being, the following workarounds can be used:

1. Use only external Git command line. Either Cygwin Git or Git for Winodws.
2. Use Eclipse embedded Git implementation and try to ignore the reported as modified links in the sync view. You cannot select them to commit them anyway afterwards.
3. Use an IDE that supports external Git implementation (e.g. IntelliJ), where the Git for Windows path can be provided to work with the core.symlinks option set to true.