Bug 405326 - "Staging" View does not properly handle symlinks
Summary: "Staging" View does not properly handle symlinks
Status: CLOSED DUPLICATE of bug 484498
Alias: None
Product: EGit
Classification: Technology
Component: Core (show other bugs)
Version: 2.3   Edit
Hardware: PC Linux
: P3 major with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 485026 (view as bug list)
Depends on: 354367
Blocks: 429304
  Show dependency tree
 
Reported: 2013-04-09 19:34 EDT by Zorzella Mising name CLA
Modified: 2015-12-30 13:04 EST (History)
6 users (show)

See Also:


Attachments
staging view for a modified symlink (20.95 KB, image/png)
2014-02-28 05:21 EST, Matthias Sohn CLA
no flags Details
Staging view showing same link as added and deleted at same time where CLI git shows it as staged for adding. (8.88 KB, image/png)
2014-07-25 03:31 EDT, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zorzella Mising name CLA 2013-04-09 19:34:23 EDT
Say there's a file "foo/bar" and a UNIX symlink "bar" to the directory "foo", all of which checked into git. A "git status" will show no entries, but EGit's "Staging" view lists "bar" as an "unstaged" change.
Comment 1 Robin Stocker CLA 2013-04-10 07:41:32 EDT
This depends on symlink support in JGit, bug 354367.
Comment 2 Matthias Sohn CLA 2013-05-11 18:21:42 EDT
symlinks aren't yet supported so this is an enhancement request
Comment 3 Matthias Sohn CLA 2014-02-28 05:19:47 EST
Now, with the recent improvements for symlink support we can reconsider this as a bug.

I found the following problems:
- symlinks aren't decorated as such in the staging view, instead they are shown as directory and their target is represented as a file under the directory node
- modifying the target of a symlink is shown as a deletion of the old symlink target and an addition of the new symlink target
Comment 4 Matthias Sohn CLA 2014-02-28 05:21:54 EST
Created attachment 240392 [details]
staging view for a modified symlink

* clone egit
* cd to org.eclipse.egit.core/src/org/eclipse/egit/core
* ln -s ../../../../../../org.eclipse.egit.ui org.eclipse.egit.ui
* add and commit the new symlink from EGit
* now change the link to point to another target
 rm org.eclipse.egit.ui
 ln -s ../../../../../../org.eclipse.egit.ui.test org.eclipse.egit.ui
* open staging view
Comment 5 Andrey Loskutov CLA 2014-07-25 03:29:48 EDT
Another problem: handling of the symlinks pointing to the non-existing files is really weird (at least on Eclipse 3.8 with latest nightly egit 3.5):

$ln -s ../nada link_to_nada
$git status .
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       link_to_nada
nothing added to commit but untracked files present (use "git add" to track)

Eclipse sees *nothing* in project explorer, staging view also shows nothing.

$git add link_to_nada
$ git status .
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   link_to_nada
#

Eclipse sees *nothing* in project explorer, staging view also shows nothing, *until I close/reopen the project*.

Now package explorer shows the project as changed (but still doesn't show the link) and staging view shows link_to_nada in both staged/unstaged areas, see attached picture. The staged area shows the right state, the unstaged shows the wrong state.

After committing the changes:

$git commit -m "added dead link"
[master 31360ba] added dead link
 1 file changed, 1 insertion(+)
 create mode 120000 link_to_nada

$git status .
# On branch master
nothing to commit, working directory clean

Eclipse staging view shows "link_to_nada" in unstaged area as deleted.

Looks like Eclipse (3.8) in general can't handle links pointing to nirvana, and so egit staging view fails here too (because it uses Eclipse resource model and not real file system?).
Comment 6 Andrey Loskutov CLA 2014-07-25 03:31:44 EDT
Created attachment 245370 [details]
Staging view showing same link as added and deleted at same time where CLI git shows it as staged for adding.
Comment 7 Axel RICHARD CLA 2014-09-09 05:33:47 EDT
(In reply to Matthias Sohn from comment #4)
> Created attachment 240392 [details]
> staging view for a modified symlink
> 
> * clone egit
> * cd to org.eclipse.egit.core/src/org/eclipse/egit/core
> * ln -s ../../../../../../org.eclipse.egit.ui org.eclipse.egit.ui
> * add and commit the new symlink from EGit
> * now change the link to point to another target
>  rm org.eclipse.egit.ui
>  ln -s ../../../../../../org.eclipse.egit.ui.test org.eclipse.egit.ui
> * open staging view

It works for me. I can reproduce only in case of wrong org.eclipse.jgit.util.FS. As a reminder the only valid FS to support symlinks is FS_POSIX_Java7.
Can you test again with the latest version of EGit ?
Comment 8 Axel RICHARD CLA 2014-09-09 05:35:47 EDT
(In reply to Andrey Loskutov from comment #6)
> Created attachment 245370 [details]
> Staging view showing same link as added and deleted at same time where CLI
> git shows it as staged for adding.

The problem is broken symlinks are not detected by the platform.
I raised a bug in Platform resources https://bugs.eclipse.org/bugs/show_bug.cgi?id=443409 to know why such symlinks are not detected and displayed in Eclipse.
Comment 9 Axel RICHARD CLA 2014-09-09 08:23:20 EDT
(In reply to Axel RICHARD from comment #7)
> It works for me. I can reproduce only in case of wrong
> org.eclipse.jgit.util.FS. As a reminder the only valid FS to support
> symlinks is FS_POSIX_Java7.

For completeness, today, MacOS-Java7, Linux-Java7 and Windows-Java7 (with administrator privileges) users can take advantage of symlinks.
Comment 10 Andrey Loskutov CLA 2015-12-16 10:23:25 EST
Broken symlinks support depends on bug 290318, but a fix for egit is possible without it - if we get rid of ContainerTreeIterator or rewrite it to use java.io instead of org.eclipse.core.resources to iterate over the directory content.

Might be I'm overlooking something but I can't get why do we need a dedicated ContainerTreeIterator at all - it limits us to the resources model of Eclipse !?!

If I replace it with AdaptableFileTreeIterator everything seems to work *and* I see properly decorated broken symbolic links in the staging view.
Comment 11 Andrey Loskutov CLA 2015-12-18 09:45:10 EST
Actually fixing bug 484498 would fix this bug too, so I declare this one as a dup of bug 484498.

*** This bug has been marked as a duplicate of bug 484498 ***
Comment 12 Andrey Loskutov CLA 2015-12-30 13:04:01 EST
*** Bug 485026 has been marked as a duplicate of this bug. ***