Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366207 - Importing projects using ProjectSetCapability fails for existing repo (multiple projects, single repo)
Summary: Importing projects using ProjectSetCapability fails for existing repo (multip...
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-09 10:24 EST by Tim Webb CLA
Modified: 2017-07-11 05:05 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Webb CLA 2011-12-09 10:24:34 EST
Build Identifier: M20110210-1200

EGit version: 1.1.0.201109151100-r

When importing projects using the ProjectSetCapability API, the import can fail if the repo is already cloned with the right branch locally.  Specifically if you use ProjectSetCapability.addToWorkspace(...)  repetitively add projects one reference URI at a time, all the subsequent projects fail with an error similar to:

Destination directory <path>/core exists. Don't clone [<project-name>] from ssh://<host>:<port><path-to-repo> to prevent data loss.

A suggestion by Robin on the egit-dev list was: "We could add additional logic that checks if a Git repository already exists with the given URI and branch, and in that case skip the clone step and directly import and connect the project."

Logging as major as the API doesn't work even after restart as well making the ability to use the team import API non-usable to sync projects using external products using said API.  Please adjust as appropriate based on project conventions.  Thanks!

Reproducible: Always

Steps to Reproduce:
1. Add one project using ProjectSetCapability.addToWorkspace(...) -- it succeeds
2. Attempt to add other projects using ProjectSetCapability.addToWorkspace(...):
   It only succeeds if the projects have different URIs / branches
   If the branch / URI is from the same repository, fails with error above.
3. Restarting Eclipse does not appear to allow it to succeed, the same error can occur on other project additions
Comment 1 Robin Stocker CLA 2011-12-10 08:18:37 EST
Pushed two changes to implement this:

* Refactor import code of GitProjectSetCapability
  http://egit.eclipse.org/r/4779

* Skip clone for import of project from existing repo
  http://egit.eclipse.org/r/4780
Comment 2 Mykola Nikishov CLA 2011-12-10 10:34:56 EST
(In reply to comment #1)

> Pushed two changes to implement this:

-2 as it will not update existing local repository, i.e.:

- clone remote repo A with one project and import it;
- someone pushed new changes to remote repo A and now it has three projects;
- someone updated PSF accordingly (it refers to three projects);
- you use this PSF and it should import three projects;
- BUT your local repository still has only one.

Am I missing something?
Comment 3 Robin Stocker CLA 2011-12-10 12:06:59 EST
This situation is only possible if you never pulled since the you imported the original repository.

But even then, I don't think we should touch the existing repositories. What are you suggesting, doing a pull? What about if there are merge conflicts?
Comment 4 Mykola Nikishov CLA 2011-12-10 13:28:56 EST
(In reply to comment #3)

> But even then, I don't think we should touch the existing repositories. What
> are you suggesting, doing a pull?

No, this is what I would expect in this situation:
- add a new remote
- fetch from it
- stash uncommitted changes if any
- switch to branch, according to PSF
- import
Comment 5 Robin Stocker CLA 2012-01-10 04:44:11 EST
(In reply to comment #4)
> (In reply to comment #3)
> 
> > But even then, I don't think we should touch the existing repositories. What
> > are you suggesting, doing a pull?
> 
> No, this is what I would expect in this situation:
> - add a new remote
> - fetch from it
> - stash uncommitted changes if any
> - switch to branch, according to PSF
> - import

Do others also think that this would be the right thing to do?
Comment 6 Matthias Sohn CLA 2012-01-17 11:31:36 EST
merged http://egit.eclipse.org/r/#change,4779
as 6ed6b9104cbce86668d6819601694f8a29a16119
Comment 7 Dariusz Luksza CLA 2012-01-22 07:24:27 EST
merged http://egit.eclipse.org/r/4780 as 03a111b4c460bb1443f50de3294da9424de0dbcd
Comment 8 Mykola Nikishov CLA 2012-01-22 14:00:50 EST
With 03a111b4c4,
-1 as there is no way to get feedback about the case from comment #2.
-1 as it makes PSF useless if you have a local clone for such project as it will SILENTLY do nothing as a result of 'Import from PSF' action.
+0 as it solves the problem that has a workaround.

So, it breaks my expectation about using PSF: it finishes w/o errors = I have all projects from this PSF in my workspace. Personally, I see no value in this change.
Comment 9 Dariusz Luksza CLA 2012-01-24 18:19:40 EST
(In reply to comment #8)
> With 03a111b4c4,
> -1 as there is no way to get feedback about the case from comment #2.
> -1 as it makes PSF useless if you have a local clone for such project as it
> will SILENTLY do nothing as a result of 'Import from PSF' action.
> +0 as it solves the problem that has a workaround.
> 
> So, it breaks my expectation about using PSF: it finishes w/o errors = I have
> all projects from this PSF in my workspace. Personally, I see no value in this
> change.

IMHO this is good starting point for further improvements and discussions. We can now continue working on proper user experience and make another small step ahead.