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

This commit is contained in:
Christian Halstrick 2015-08-17 03:54:23 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 91b1ab90e2
2 changed files with 7 additions and 1 deletions

View File

@ -866,7 +866,10 @@ protected ProcessResult internalRunHookIfPresent(Repository repository,
* @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;
}

View File

@ -335,6 +335,9 @@ public String normalize(String name) {
@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))