Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348938 - Create sync project fails if remote directory contains .git
Summary: Create sync project fails if remote directory contains .git
Status: CLOSED FIXED
Alias: None
Product: PTP
Classification: Tools
Component: RDT.sync (show other bugs)
Version: 5.0   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: John Eblen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-09 13:52 EDT by Greg Watson CLA
Modified: 2011-07-08 10:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Watson CLA 2011-06-09 13:52:16 EDT
When creating a new synchronized project, if the remote directory already contains .git, then the initial sync will fail with:

org.eclipse.ptp.rdt.sync.git.core.RemoteSyncException: 
	at org.eclipse.ptp.rdt.sync.git.core.GitRemoteSyncConnection.syncLocalToRemote(GitRemoteSyncConnection.java:575)
	at org.eclipse.ptp.rdt.sync.git.core.GitServiceProvider.synchronize(GitServiceProvider.java:257)
	at org.eclipse.ptp.internal.rdt.sync.core.ResourceChangeListener$SynchronizeJob.run(ResourceChangeListener.java:73)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.ptp.rdt.sync.git.core.RemoteExecutionException: Remote merge failed with message: 
	at org.eclipse.ptp.rdt.sync.git.core.GitRemoteSyncConnection.syncLocalToRemote(GitRemoteSyncConnection.java:576)
	... 3 more
org.eclipse.ptp.rdt.sync.git.core.RemoteSyncException: 
	at org.eclipse.ptp.rdt.sync.git.core.GitRemoteSyncConnection.syncLocalToRemote(GitRemoteSyncConnection.java:575)
	at org.eclipse.ptp.rdt.sync.git.core.GitServiceProvider.synchronize(GitServiceProvider.java:257)
	at org.eclipse.ptp.internal.rdt.sync.core.ResourceChangeListener$SynchronizeJob.run(ResourceChangeListener.java:73)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.ptp.rdt.sync.git.core.RemoteExecutionException: Remote merge failed with message: fatal: 'merge' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.

	at org.eclipse.ptp.rdt.sync.git.core.GitRemoteSyncConnection.syncLocalToRemote(GitRemoteSyncConnection.java:576)
	... 3 more
Comment 1 Greg Watson CLA 2011-06-10 14:18:32 EDT
The sync also fails if the remote directory contains .settings. Even though I added it to FileFilter, it still seems to be trying to sync. Perhaps becuase it is a directory and not a file?
Comment 2 John Eblen CLA 2011-06-10 15:54:40 EDT
Yes, the code in the FileFilter is incorrect:

fileName.endsWith(".settings")

Since we are filtering a directory, we have to check for .settings anywhere in the file name, not just at the end.
Comment 3 Greg Watson CLA 2011-06-13 09:27:49 EDT
I changed String#endsWith() to #equals() for .project and .cproject and #startsWith() for .settings. This seems to do the job now.

The .git issue still remains though.
Comment 4 John Eblen CLA 2011-06-14 14:36:00 EDT
I think these merge conflicts could be legitimate. It depends on the state of the remote project. Sync does not and should not overwrite the git information already present in .git. So if the repo was already in the middle of a merge conflict, that will not change. As another example, a new managed project will cause a merge conflict if the remote already has a Makefile, because it is trying to overwrite the Makefile already there. If I create a new empty project, however, and point it to a project already containing a .git, it works fine. So, other than finding a way to handle merge conflicts better, I think this may not be a bug.

Can you give more details about the contents of the existing project?
Comment 5 Greg Watson CLA 2011-06-14 14:53:27 EDT
I'm sure the merge conflicts are correct. However, when creating a new sync project, it should at least check to see if the remote directory already contains .git and either a) refuse to sync or b) remove the .git (after asking the user to confirm). The presence of a .git directory either indicates the project was synchronized in the past, or was cloned from another repository. I don't think you want to keep the Git information in either of these cases.
Comment 6 Roland Schulz CLA 2011-06-14 15:34:44 EDT
(In reply to comment #5)
> The presence of a .git directory either indicates the
> project was synchronized in the past, or was cloned from another repository. I
> don't think you want to keep the Git information in either of these cases.

I think we should keep the Git information if it was clone from another repository. At the moment we cannot use that information very well, but in the long run it should be possible to keep the Git repository information (as revision control system) and have the synchronized information not interfere (e.g. separate branch).
Comment 7 John Eblen CLA 2011-07-08 10:25:06 EDT
Sync'ing is now done using a separate Git directory (.ptp-sync). So this is no longer a problem (.git directories are ignored).