git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: "Shawn O. Pearce" <spearce@spearce.org>, git <git@vger.kernel.org>
Subject: [EGIT PATCH 1/1] Some error handling for GitDocument
Date: Mon, 3 Nov 2008 00:46:21 +0100	[thread overview]
Message-ID: <200811030046.22265.robin.rosenberg@dewire.com> (raw)

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

                 reply	other threads:[~2008-11-02 23:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200811030046.22265.robin.rosenberg@dewire.com \
    --to=robin.rosenberg@dewire.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).