Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324826

Summary: [sync] Checkbox "Include local uncommitted changes..." does not work
Product: [Technology] EGit Reporter: Stefan Lay <stefan.lay>
Component: UIAssignee: Project Inbox <egit.ui-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dariusz.luksza
Version: 0.9.0   
Target Milestone: 0.10.0-M1   
Hardware: All   
OS: All   
Whiteboard:

Description Stefan Lay CLA 2010-09-09 05:14:36 EDT
In the Synchronize repository dialog there is a checkbox "Include local uncommitted changes in comparison". It does not do what it says. It always uses the local state of the resource. 

I checked the code in GitResourceVariantComparator.getLocal(IResource resource):

if resource.getProject().getName() is false I would expect that the content from the commit is used. Instead a workspace refresh takes place and the local state is used.

Another issue is the following: when I open the compare editor with a double click the left side always displays the local state. But here things are more complicated. The method GitResourceVariantComparator.getLocal(IResource resource) is not called here, but ModelSynchronizeParticipant.asCompareInput:

Thread [main] (Suspended)	
	org.eclipse.egit.ui.internal.synchronize.GitModelSynchronizeParticipant(org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant).asCompareInput(java.lang.Object) line: 306	
	org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction.openCompareEditor(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration, java.lang.Object, boolean, boolean) line: 110	
	org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction.run() line: 65
Comment 1 Dariusz Luksza CLA 2010-09-17 19:03:05 EDT
(In reply to comment #0)
> In the Synchronize repository dialog there is a checkbox "Include local
> uncommitted changes in comparison". It does not do what it says. It always uses
> the local state of the resource. 
> 
> I checked the code in GitResourceVariantComparator.getLocal(IResource
> resource):
> 
> if resource.getProject().getName() is false I would expect that the content
> from the commit is used. Instead a workspace refresh takes place and the local
> state is used.

From my quick tests appears that GitResourceVariantComparator.getLocal() is never used when !gsd.shouldInculdeLocal() therefore no changes are required in it implementation so that if would be able to obtain a file version from Git (another thing is that, we actually don't need there if statement).

> Another issue is the following: when I open the compare editor with a double
> click the left side always displays the local state. But here things are more
> complicated. The method GitResourceVariantComparator.getLocal(IResource
> resource) is not called here, but ModelSynchronizeParticipant.asCompareInput:

Yes, GitResourceVariantComparator.getLocal() isn't called because we use ModelSynchronizeParticipant instead of simple SynchronizeParticipant. But we can "hook" here our git specific ICompareInput implementation. I've test it and in case of Workspace model we get IFile instance in GitModelSynchronizeParticipant.asCompareInput(), base on this information we can return here mentioned above git specific ICompareInput preconfigured for given file. Thanks Stefan for finding this!

Now we could include Git Model and Workspace model when synchronization without local changes is launched!
Comment 2 Dariusz Luksza CLA 2010-09-17 19:09:50 EDT
Change set that fix this issue is here:
http://egit.eclipse.org/r/1623
Comment 3 Dariusz Luksza CLA 2010-09-20 16:27:52 EDT
Fixed with commit:
2b1814e12235a968ccfffc14231ddd491b43ecdc