BlameCache: handle null source commit
BlameServlet properly handles these null results when rendering the
output, but when the cache code was extracted we did not properly
check for null.
Change-Id: I18cd1cda9b1df379c107f0d899161be3b6e9f514
diff --git a/gitiles-servlet/src/main/java/com/google/gitiles/BlameCache.java b/gitiles-servlet/src/main/java/com/google/gitiles/BlameCache.java
index b996048..1b3a2d3 100644
--- a/gitiles-servlet/src/main/java/com/google/gitiles/BlameCache.java
+++ b/gitiles-servlet/src/main/java/com/google/gitiles/BlameCache.java
@@ -49,8 +49,14 @@
Region(BlameResult blame, int start) {
this.sourcePath = blame.getSourcePath(start);
RevCommit c = blame.getSourceCommit(start);
- this.sourceCommit = c.copy();
- this.sourceAuthor = c.getAuthorIdent();
+ if (c != null) {
+ this.sourceCommit = c.copy();
+ this.sourceAuthor = c.getAuthorIdent();
+ } else {
+ // Unknown source commit due to JGit bug.
+ this.sourceCommit = null;
+ this.sourceAuthor = null;
+ }
this.count = 1;
}