Skip to main content



      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 11:34 Go to next message
Eclipse UserFriend
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 12:56 Go to previous messageGo to next message
Eclipse UserFriend
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 13:30 Go to previous messageGo to next message
Eclipse UserFriend
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 13:45 Go to previous messageGo to next message
Eclipse UserFriend
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 09:48 Go to previous messageGo to next message
Eclipse UserFriend
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 13:52 Go to previous messageGo to next message
Eclipse UserFriend
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 15:52 Go to previous messageGo to next message
Eclipse UserFriend
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 08:11 Go to previous messageGo to next message
Eclipse UserFriend
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 09:37 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1856985 is a reply to message #1849664] Wed, 11 January 2023 12:42 Go to previous messageGo to next message
Eclipse UserFriend
It's been a year since I investigated this issue. I'm at the point where I may abandon replicating the EGit clone and import project(s) code. I've recommended (to our C/C++ developers) a workaround of using Import->Projects from Git (with smart import) with the URI. It comes down to whether the EGit plug-in has any public APIs I could use to clone and import. Having the possibility of my plug-in breaking anytime I move to a new version of Eclipse/EGit is not sustainable. Thanks in advance for any comments.
Regards, Jim
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1856995 is a reply to message #1856985] Thu, 12 January 2023 02:58 Go to previous messageGo to next message
Eclipse UserFriend
It sounds like you're trying to do something that Oomph also does. Many projects have Oomph setups that automate the whole process of setting up an IDE and its workspace. Maybe you can just reuse that? I'm not sure about "smart import", but just a regular import works in you include the .project files and such in the repository...

https://wiki.eclipse.org/Eclipse_Oomph_Authoring
https://wiki.eclipse.org/Eclipse_Platform_SDK_Provisioning
Re: Git clone of a source code into a parent C project doesn't appear to work? [message #1857000 is a reply to message #1856995] Thu, 12 January 2023 07:23 Go to previous message
Eclipse UserFriend
Thanks, Ed. I'll look at Oomph.
Previous Topic:Paths with spaces in .gitconfig
Next Topic:Cannot launch nested eclipse
Goto Forum:
  


Current Time: Mon May 19 18:20:22 EDT 2025

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

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

Back to the top