Skip to contentSkip to conversation

Some error handling for GitDocument

PATCH New Robin Rosenberg 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Some error handling for GitDocument

We sometimes (rarely) gets errors from unresolvable trees. Do not just throw a NullPointerException.

---

This is primarily necessary to track down a rare problem, but we should have error handling here anyway.

 .../egit/ui/internal/decorators/GitDocument.java   |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java +9 -1
index 3724304..6e10144 100644
@@ -21,6 +21,7 @@
 import org.spearce.jgit.lib.RefsChangedEvent;
 import org.spearce.jgit.lib.Repository;
 import org.spearce.jgit.lib.RepositoryListener;
+import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.TreeEntry;
 
 class GitDocument extends Document implements RepositoryListener {
@@ -52,7 +53,14 @@ void populate() throws IOException {
 		String baseline = GitQuickDiffProvider.baseline.get(repository);
 		if (baseline == null)
 			baseline = "HEAD";
-		TreeEntry blobEnry = repository.mapTree(baseline).findBlobMember(gitPath);
+		Tree baselineTree = repository.mapTree(baseline);
+		if (baselineTree == null) {
+			Activator.logError("Could not resolve quickdiff baseline "
+					+ baseline + " corresponding to " + resource + " in "
+					+ repository, new Throwable());
+			return;
+		}
+		TreeEntry blobEnry = baselineTree.findBlobMember(gitPath);
 		if (blobEnry != null) {
 			Activator.trace("(GitQuickDiffProvider) compareTo: " + baseline);
 			ObjectLoader loader = repository.openBlob(blobEnry.getId());
Signature · 1 line
1.6.0.3.578.g6a50