Let RepositoryBuilder find bare repos

BaseRepositoryBuilder.findGitDir() was not searching correctly for bare
repositories. E.g. when running org.eclipse.jgit.pgm.Log and the current
directory was that of a bare git repository an error "fatal: error:
can't find git directory" was raised. With this fix RepositoryBuilder
will also check whether the given directory is the root of a bare
repository.

Bug: 450193
Change-Id: I4d4ad42e24ca397745adb0f3385caee3bcf3a186
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Christian Halstrick 2014-11-07 13:15:11 +01:00 committed by Matthias Sohn
parent 5672535360
commit 140df39198
1 changed files with 5 additions and 1 deletions

View File

@ -514,13 +514,17 @@ public B findGitDir(File current) {
if (FileKey.isGitRepository(dir, tryFS)) {
setGitDir(dir);
break;
} else if (dir.isFile())
} else if (dir.isFile()) {
try {
setGitDir(getSymRef(current, dir, tryFS));
break;
} catch (IOException ignored) {
// Continue searching if gitdir ref isn't found
}
} else if (FileKey.isGitRepository(current, tryFS)) {
setGitDir(current);
break;
}
current = current.getParentFile();
if (current != null && ceilingDirectories != null