Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Need help on submodules support with jgit API.(Need help on submodules support with jgit API.)
Need help on submodules support with jgit API. [message #965710] Wed, 31 October 2012 12:56
Madhusudhan Ramachandra is currently offline Madhusudhan RamachandraFriend
Messages: 1
Registered: October 2012
Junior Member
Hi All,

I'm trying to clone a repository on github which has submodules within it. The code i'm using to clone the repository is

String PATH = "C:/Madhu/GIT/Submodules";
File directory = new File(PATH);
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(directory).readEnvironment().findGitDir().build();

Git git = new Git(repository);
CloneCommand clone = git.cloneRepository();
clone.setCloneSubmodules(true);
clone.setDirectory(directory).setURI("URL_TO_GITHUB_REPOSITORY");
UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider("username", "password");
clone.setCredentialsProvider(user);
clone.call();


I can see the repository created on my local directory. i can also see the .gitmodules file which has the list of submodules within it. I need to parse through all the submodules to get the path and the url of each submodules. For this purpose i'm trying to create a SubmoduleWalk. The code snippet i'm using to create a SubmoduleWalk is

SubmoduleWalk generator = SubmoduleWalk.forIndex(git.getRepository());
generator.setTree(new DirCacheIterator(git.getRepository().readDirCache()));


when i execute the above code snippet, i'm getting the below exception

Exception in thread "main" org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
at org.eclipse.jgit.lib.Repository.getIndexFile(Repository.java:967)
at org.eclipse.jgit.dircache.DirCache.read(DirCache.java:166)
at org.eclipse.jgit.lib.Repository.readDirCache(Repository.java:991)
at org.eclipse.jgit.submodule.SubmoduleWalk.forIndex(SubmoduleWalk.java:95)
at git.clone.GitClone.main(GitClone.java:49)


I'm using jgit version 2.1.0.201209190230-r.

I had read about insufficient support for submodules in jgit. I believe this is fixed with the version 1.2 or higher.

Can anyone please suggest what might be wrong in this case? Any help is much appreciated.

Thank you.

Regards,
Madhusudhan
Previous Topic:Plugin to visualize class hierachy and dependencies.
Next Topic:Eclipse does not found JDK (again, I know)
Goto Forum:
  


Current Time: Mon Dec 22 16:22:08 GMT 2014

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

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