Skip to content

Commit f3ec761

Browse files
committed
fallback to newer file if genre for older file is null
fixes #832
1 parent 4935d44 commit f3ec761

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/org/opensolaris/opengrok/web/PageConfig.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public DiffData getDiffData() {
189189
if (data.genre == null || txtGenres.contains(data.genre)) {
190190
InputStream[] in = new InputStream[2];
191191
try {
192+
// Get input stream for both older and newer file.
192193
for (int i = 0; i < 2; i++) {
193194
File f = new File(srcRoot + filepath[i]);
194195
in[i] = HistoryGuru.getInstance().getRevision(f.getParent(), f.getName(), data.rev[i]);
@@ -200,12 +201,17 @@ public DiffData getDiffData() {
200201
}
201202
}
202203

203-
if (data.genre == null) {
204+
/*
205+
* If the genre of the older revision cannot be determined,
206+
* (this can happen if the file was empty), try with newer
207+
* version.
208+
*/
209+
for (int i = 0; i < 2 && data.genre == null; i++) {
204210
try {
205-
data.genre = AnalyzerGuru.getGenre(in[0]);
211+
data.genre = AnalyzerGuru.getGenre(in[i]);
206212
} catch (IOException e) {
207213
data.errorMsg = "Unable to determine the file type: "
208-
+ Util.htmlize(e.getMessage());
214+
+ Util.htmlize(e.getMessage());
209215
}
210216
}
211217

0 commit comments

Comments
 (0)