Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Git clone of a source code into a parent C project doesn't appear to work?(Git clone of a source code into a parent C project doesn't appear to work?)
Git clone of a source code into a parent C project doesn't appear to work? [message #1849605] Wed, 26 January 2022 16:34 Go to next message
James Poli is currently offline James PoliFriend
Messages: 13
Registered: January 2022
Junior Member
I have an Eclipse plug-in that clones a C source with org.eclipse.egit.core.op.run() into a parent project C it creates for handling build output. It then imports C source into the parent C project it via org.eclipse.egit.ui.internal.clone.createProjects(). I can see the source code in the Eclipse Package Explorer and Git perspective. However, modified files aren't marked with ">" in front of the filename? Is this a valid scenario? I've inherited this code and am not sure it ever worked?
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849609 is a reply to message #1849605] Wed, 26 January 2022 17:56 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1213
Registered: July 2009
Senior Member
Without seeing the source code of your plugin that's hard to answer.
Why don't you use EGit to clone the repository ?
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849611 is a reply to message #1849609] Wed, 26 January 2022 18:30 Go to previous messageGo to next message
James Poli is currently offline James PoliFriend
Messages: 13
Registered: January 2022
Junior Member
It is a helper plug-in that takes care of that plus set-up of the project, which requires more than a clone in EGit. Perhaps a better question is can EGit associate a cloned sub-folder to a parent project?
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849612 is a reply to message #1849611] Wed, 26 January 2022 18:45 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1213
Registered: July 2009
Senior Member
Try to clone the repository and then use import from existing project
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849640 is a reply to message #1849612] Thu, 27 January 2022 14:48 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 497
Registered: August 2016
Senior Member
Sounds like the project is not connected to the Eclipse "Team provider" for EGit. But without seeing real code that shows what exactly your plug-in does it's hard to give any concrete help.

Obligatory cautionary note: using EGit internal classes may break at any time between EGit versions.
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849649 is a reply to message #1849640] Thu, 27 January 2022 18:52 Go to previous messageGo to next message
James Poli is currently offline James PoliFriend
Messages: 13
Registered: January 2022
Junior Member
Thanks, Thomas. The clone is below:

CloneOperation operation = new CloneOperation(uri, true, null, trgFile, branch, "origin", 10000);
try {
	operation.addPostCloneTask(new PostCloneTask() {
		public void execute(Repository repository, IProgressMonitor monitor) throws CoreException {
			localRepositories.add(repository.getDirectory().getAbsolutePath());
			options.put(GitSCMWizardPage.KEY_SELECTED_LOCAL_REPOS, localRepositories);
		}
	});
	operation.run(monitor);
} catch (InvocationTargetException e) {
    ...
}


Here is the import:

private void importProjects(IProgressMonitor monitor) throws IOException, InvocationTargetException,
			InterruptedException
{
	Repository repo = getTargetRepository(rootDirectory);
	Set<ProjectRecord> projectsToCreate = getProjectRecords();

	ProjectUtils.createProjects(projectsToCreate, true,null, monitor);
	boolean isEclipseLunaRelease = false;
}


FWIW, I saw your Obligatory cautionary note. This code is old and appears very fragile. I'm not surprised it isn't working.
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849652 is a reply to message #1849649] Thu, 27 January 2022 20:52 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 497
Registered: August 2016
Senior Member
Provided the ProjectRecords are correct, this should work. I'm a bit confused because "repo" isn't used inside importProjects(). This seems to show only the relevant parts? I fear you'll have to debug this to find out what exactly happens inside createProjects(). If something goes wrong in there (such as "mapping" being null), it's possible that the project is created, but the ConnectProviderOperation at the end isn't run on it. Or perhaps there's something in the ConnectProviderOperation that fails.

Apparently your code even targets Eclipse Luna? What version of EGit do you use? EGit 5.0.3.201809091024-r is the last version that worked on Luna.

Perhaps you're also running into a similar problem as in https://www.eclipse.org/forums/index.php/t/1108254/ , which was fixed for EGit 5.13. But if you're using an old EGit version, this fix cannot be applied as-is.
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849660 is a reply to message #1849652] Fri, 28 January 2022 13:11 Go to previous messageGo to next message
James Poli is currently offline James PoliFriend
Messages: 13
Registered: January 2022
Junior Member
Thanks again, Thomas. I believe you are correct that I'll need to debug this and step through createProjects(). I think the original intent by the developer was to have one plug-in that supported all back versions of Eclipse. I upgraded the code to Eclipse 2021-09 (4.21.0), using EGit 5.13.0.202109080827-r. Once I get this working, I need to pass and clean up unused variables and outdated code (Luna).
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1849664 is a reply to message #1849660] Fri, 28 January 2022 14:37 Go to previous message
James Poli is currently offline James PoliFriend
Messages: 13
Registered: January 2022
Junior Member
I believe I found the issue in createProjects(). The method ConnectProviderOperation() is never called since projectsToConnect.isEmpty() is true. This method finder.setFindInChildren(false) has defaulted, and since this is a nested repository and a parent project/folder causes the repository never to be found. It works if I change projectsToCreate record to point to the nested repository instead of the parent. But I lost the parent project view in the Package Explorer, and the project's build failed. I"m stuck, it appears.
Previous Topic:Always getting 'remote hung up unexpectedly' when cloning eclipse.platform.ui over ssh
Next Topic:How to manage multiple projects within the same repo
Goto Forum:
  


Current Time: Mon Oct 03 22:23:15 GMT 2022

Powered by FUDForum. Page generated in 0.06684 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top