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();
UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider("username", "password");

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(
at org.eclipse.jgit.lib.Repository.readDirCache(
at org.eclipse.jgit.submodule.SubmoduleWalk.forIndex(
at git.clone.GitClone.main(

I'm using jgit version

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.

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

Current Time: Thu Nov 26 10:44:59 GMT 2015

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

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