| Summary: | Automagic detection of GIT_DIR fails | ||
|---|---|---|---|
| Product: | [Technology] JGit | Reporter: | Ketan Padegaonkar <KetanPadegaonkar> |
| Component: | JGit | Assignee: | Christian Halstrick <christian.halstrick> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sop, stefan.lay |
| Version: | 0.9.0 | ||
| Target Milestone: | 0.9.0 | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
Fixed by change I64205bb0315a725dfa523ccff1796de50f465162 |
rev 11c5c9 of jgit. I'd expect that running 'jgit log' on the command line would behave in a (mostly) similar way with 'git log' with respect to detection of the .git directory. Specifically, the javadoc for RepositoryBuilder#findGitDir(File) mentions that '[it] Starts from the supplied directory path and scans up through the parent directory tree until a Git repository is found'. However it does not quite behave in the way that it documents. This is because ceilingDirectories is null/empty at the time this method is called. storm:~/projects/dev/jgit git (master)$ java -jar org.eclipse.jgit.pgm/target/jgit-cli.jar log > /dev/null As expected, everything is fine, and there is no error. Now lets do the same in a sub dir: storm:~/projects/dev/jgit/org.eclipse.jgit.pgm git (master)$ java -jar target/jgit-cli.jar log > /dev/null java.lang.NullPointerException at org.eclipse.jgit.lib.BaseRepositoryBuilder.findGitDir(BaseRepositoryBuilder.java:417) at org.eclipse.jgit.lib.BaseRepositoryBuilder.findGitDir(BaseRepositoryBuilder.java:387) at org.eclipse.jgit.pgm.Main.execute(Main.java:166) at org.eclipse.jgit.pgm.Main.main(Main.java:99) Here is a failing test case that can reproduce the error, that you may add to the jgit test suite. public class RepositoryBuilderTest extends LocalDiskRepositoryTestCase { public void testShouldAutomagicallyDetectGitDirectory() throws Exception { FileRepository repository = createWorkRepository(); File subDir = new File(repository.getDirectory(), "sub-dir"); subDir.mkdir(); assertEquals(repository.getDirectory(), new RepositoryBuilder().findGitDir(subDir)); } }