Browse Source

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>
stable-3.6
Christian Halstrick 10 years ago committed by Matthias Sohn
parent
commit
140df39198
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java

@ -514,13 +514,17 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
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

Loading…
Cancel
Save