DESCRIPTION

Fix GitModelObject adaptation to IResource

A GitModelObject returns the full absolute path to the object in the git
working tree. Using that for IWorkspaceRoot.getFile() creates a resource
with that as path, not as location. Which result in all deleted
resources having bogus paths in the Git Model of the Synchronize View.

This change maps back the git absolute path to a workspace-relative path
that can then safely be used with IWorkspaceRoot.getFile().

Adapting a GitModelObject to an IResource will work only for files
actually in the Eclipse workspace. Changing that so that it works also
for files in the working tree, but not in the workspace is _not_ fixed
by this change.

Change-Id: Ie539c3ad46f3f48ac6f01a365d20ceacd8952564
Signed-off-by: Alayna Houston xxx@xxx.xxx

COMMENTS

author: Brenden Conley
date: 2015-12-05 09:21:11.000000000

Patch Set 3:

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

-------------------------------------
author: Brenden Conley
date: 2015-12-05 09:45:08.000000000

Patch Set 3: Verified+1

Build Successful 

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

-------------------------------------
author: Jayvion Booth
date: 2015-12-05 19:01:24.000000000

Patch Set 3:

(6 comments)

> (1 comment)
 > Synchronize View appears to be pretty much broken for non-workspace files.

I personally never used this view in Git. I learned to hate it back in times I tried to implement support for it for Mercurial plugin. It makes no sense for Git and the team framework abstractions (or limitations) were simply not helpful. EGit has "others" branches in the history view and my changes in the staging view, I never felt I need any extra UI like synchronize view.

Line:140, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> I would name it getResourceFromAbsolutePath() and move to ResourceUtils, of course with some extra javadoc to explain what to expect from it.

Line:149, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> project*s*

Line:150, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Arrays.asList? I had to grock why do we need a singleton here.

Line:151, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> never null (we should annotate it in the ProjectUtil)

Line:153, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> paranoia, but IResource.getLocation() can be null.

Line:156, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> this is not needed, since one can ask project directly with the project relative path.
return project.getFile(projectRelativePath);

-------------------------------------
author: Alayna Houston
date: 2015-12-05 19:30:35.000000000

Patch Set 3:

(6 comments)

> I personally never used this view in Git.

:-) Neither do I. But it is a question of software quality: if we do provide the Synchronize View, it had better work. Otherwise, we should decide to drop this whole synchronization business and point any CVS/SVN die-hard to the staging view. (Which for git, is a *much* better way to work; and which just works.)

Line:140, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> I don't think we'll need such a construction anywhere else. For existing resources, there's already resourceUtil.getFileForLocation(). This operation here handles the case of deleted resources, and apart from the Synchronize View (and thus GitModelObjects), where else would we expect that? The staging view doesn't need it; it already can deal with deletions fine.

Line:149, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> I know it could be several. The first one will be the closest, and we're only interested in that.

But I'll rename.

Line:150, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> In either case we just need to turn a single string into a collection of one string here. Personally, I prefer the Collections.singleton* operations for that, and reserve Arrays.asList for cases where I really want to convert an array into a list.

Line:151, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Ok.

Line:153, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Not here, I think. ProjectUtil wouldn't have returned it.

Line:156, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Ok.

-------------------------------------
author: Alayna Houston
date: 2015-12-06 13:52:13.000000000

Patch Set 3:

(3 comments)

Line:149, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Done

Line:151, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Done. Annotations in ProjectUtil not done; left for a later change.

Line:156, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/factories/GitAdapterFactory.java -> Done

-------------------------------------
author: Gerrit Johnathan Pham
date: 2015-12-06 22:50:17.000000000

Change has been successfully merged into the git repository by Jayvion Booth

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