DESCRIPTION

Support compare editor on symlink changes

Bug: 484494
Change-Id: I58d2a5d969886fc00e5aee8f7b83ac57cf6cfa7f
Signed-off-by: Jayvion Booth xxx@xxx.xxx


COMMENTS

author: Jayvion Booth
date: 2015-12-17 09:53:28.000000000

Uploaded patch set 2.

-------------------------------------
author: Brenden Conley
date: 2015-12-17 09:53:34.000000000

Patch Set 2:

Build Started https://hudson.eclipse.org/egit/job/egit.gerrit/7967/

-------------------------------------
author: Brenden Conley
date: 2015-12-17 10:17:19.000000000

Patch Set 2: Verified+1

Build Successful 

https://hudson.eclipse.org/egit/job/egit.gerrit/7967/ : SUCCESS

-------------------------------------
author: Alayna Houston
date: 2015-12-17 20:27:53.000000000

Patch Set 2: Code-Review-1

Seems to work on MacOS for valid links. Apparently also for broken links.

However, I'm extremely wary of having these links editable in the compare editor. I get very strange things and follow-up errors if I edit a link in the compare editor and make it invalid in doing so.

And I didn't even try to do really bad things, like setting the link content to multiple lines of text.

In particular:

0. Start off with a valid link in the workspace, pointing to another file in the workspace. (Link created with ln -s in shell, committed in shell, then pulled in EGit.)
1. Select "Context menu->Compare with index" and edit the workspace link's contents (append a zero to make it invalid -- assuming there is no such file). Save.
2. Link is shown in staging view as deleted. cgit git status reports it as modified.
3. Stage and commit the broken link in EGit. 
4. On disk, the broken link is still there! No error logged. Compare editor remains open. cgit reports the broken link suddenly as untracked.
5. Do a "Reset Hard" on the parent commit. Now the valid link does not re-appear in package explorer. Even worse, it's gone on disk! cgit git status reports it as a staged deletion, and so does EGit's staging view. If I do the hard reset instead using cgit, the link is restored fine. Looks like EGit/JGit cannot restore a valid link if the workspace contains a broken link in that place.

Other case:

0: Start off with a valid top-level valid link (top-level is not in workspace) pointing to a file inside a project.
1. On disk, break the link by doing ln -s doesntexist.txt link.txt
2. In Eclipse, refresh staging view.
2. Link is shown in git staging view as unstaged modification. Agrees with cgit.
3. Stage and commit.
4. In Eclipse, do a Reset hard on the parent commit (with the valid link). Fails with
  java.io.IOException: Could not delete file /Users/thomas/Git/testproject_b/link.txt
	at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:176)
	at org.eclipse.jgit.util.FileUtils.createSymLink(FileUtils.java:415)
	at org.eclipse.jgit.util.FS.createSymLink(FS.java:744)
	at org.eclipse.jgit.dircache.DirCacheCheckout.checkoutEntry(DirCacheCheckout.java:1251)
	at org.eclipse.jgit.dircache.DirCacheCheckout.doCheckout(DirCacheCheckout.java:455)
	at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:401)
	at org.eclipse.jgit.api.ResetCommand.checkoutIndex(ResetCommand.java:386)
	at org.eclipse.jgit.api.ResetCommand.call(ResetCommand.java:203)

I realize that these errors have nothing to do with this change here. Maybe they're even due to my being on a Mac and having a somewhat oldish git version 1.7.7.5 (Apple Git-26) there.

Nevertheless I would advise against making link contents editable. I don't think that's a good idea. Showing the link content is, but not editing it. Let's make the compare editor read-only for links in workspace or index.

-------------------------------------
author: Jayvion Booth
date: 2015-12-17 21:01:16.000000000

Patch Set 2:

I forgot to mention, you need the latest jgit (my commit fixing symlinks checkout was merged today). With this, your errors schould disappear.

-------------------------------------
author: Jayvion Booth
date: 2015-12-17 21:10:12.000000000

Patch Set 2:

We could make it configurable and by default do not allow editing symlinks. Also we could restrict changes to use a single line only for the link. I personally think that this is OK to edit links (we do it on command line, so why not in the IDE). Actually this was what I wanted to do initially and why I discovered this bug.

-------------------------------------
author: Gerrit Johnathan Pham
date: 2015-12-24 00:41:50.000000000

Change has been successfully merged into the git repository by Douglas Trujillo

-------------------------------------
