Skip to content

Commit dd78c01

Browse files
authored
return right away from getHistory() if repository cannot be found (#4440)
1 parent fe7f812 commit dd78c01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ public History getHistory(File file, boolean withFiles, boolean ui, boolean fall
491491
final File dir = file.isDirectory() ? file : file.getParentFile();
492492
final Repository repository = getRepository(dir);
493493

494+
if (repository == null) {
495+
LOGGER.log(Level.WARNING, "no repository found for ''{0}''", file);
496+
return null;
497+
}
498+
494499
History history;
495500
try {
496501
history = getHistoryFromCache(file, repository, withFiles);
@@ -1183,8 +1188,9 @@ List<Repository> getReposFromString(Collection<String> repositories) {
11831188
/**
11841189
* Lookup repository for given file.
11851190
* @param file file object source root
1186-
* @return repository object
1191+
* @return repository object or {@code null} if not found
11871192
*/
1193+
@Nullable
11881194
public Repository getRepository(File file) {
11891195
return repositoryLookup.getRepository(file.toPath(), repositoryRoots.keySet(), repositories,
11901196
PathUtils::getRelativeToCanonical);

0 commit comments

Comments
 (0)