git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 1/1] Some error handling for GitDocument

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Nov 2, 2008, 23:46 UTC
Message-ID
<200811030046.22265.robin.rosenberg@dewire.com>

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

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

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(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
index 3724304..6e10144 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
@@ -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());
-- 
1.6.0.3.578.g6a50
Message 1 of 1 in “Some error handling for GitDocument”
  1. 1/1 Some error handling for GitDocumentRobin Rosenberg, Nov 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.