Need help on submodules support with jgit API. [message #965710] |
Wed, 31 October 2012 08:56 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04135 seconds