Browse Source

Merge "Change FS not to throw NPE when facing InMemory databases"

stable-4.1
Christian Halstrick 9 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
91b1ab90e2
  1. 5
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
  2. 3
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

5
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

@ -866,7 +866,10 @@ public abstract class FS {
* @since 4.0
*/
public File findHook(Repository repository, final String hookName) {
final File hookFile = new File(new File(repository.getDirectory(),
File gitDir = repository.getDirectory();
if (gitDir == null)
return null;
final File hookFile = new File(new File(gitDir,
Constants.HOOKS), hookName);
return hookFile.isFile() ? hookFile : null;
}

3
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

@ -335,6 +335,9 @@ public class FS_POSIX extends FS {
@Override
public File findHook(Repository repository, String hookName) {
final File gitdir = repository.getDirectory();
if (gitdir == null) {
return null;
}
final Path hookPath = gitdir.toPath().resolve(Constants.HOOKS)
.resolve(hookName);
if (Files.isExecutable(hookPath))

Loading…
Cancel
Save