All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org, Marek Zawirski <marek.zawirski@gmail.com>
Subject: [PATCH] Fix nullpointer exceptions in Quickdiff
Date: Fri, 11 Jul 2008 23:34:47 +0200	[thread overview]
Message-ID: <200807112334.47552.robin.rosenberg@dewire.com> (raw)
In-Reply-To: <1215729672-26906-2-git-send-email-robin.rosenberg@dewire.com>


--- 
I saw some problem when resources were no longer in the worspace, such as during a bisectg. 
This one should probably just be squashed into patch 1.

-- robin

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 ebed0cf..3724304 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
@@ -43,7 +43,10 @@ class GitDocument extends Document implements RepositoryListener {
 	void populate() throws IOException {
 		set("");
 		final IProject project = resource.getProject();
-		final String gitPath = RepositoryMapping.getMapping(project).getRepoRelativePath(resource);
+		RepositoryMapping mapping = RepositoryMapping.getMapping(project);
+		if (mapping == null)
+			return;
+		final String gitPath = mapping.getRepoRelativePath(resource);
 		final Repository repository = getRepository();
 		repository.addRepositoryChangedListener(this);
 		String baseline = GitQuickDiffProvider.baseline.get(repository);
@@ -63,7 +66,9 @@ class GitDocument extends Document implements RepositoryListener {
 	}
 
 	void dispose() {
-		getRepository().removeRepositoryChangedListener(this);
+		Repository repository = getRepository();
+		if (repository != null)
+			repository.removeRepositoryChangedListener(this);
 	}
 
 	public void refsChanged(final RefsChangedEvent e) {
@@ -81,6 +86,8 @@ class GitDocument extends Document implements RepositoryListener {
 	private Repository getRepository() {
 		IProject project = resource.getProject();
 		RepositoryMapping mapping = RepositoryMapping.getMapping(project);
-		return mapping.getRepository();
+		if (mapping != null)
+			return mapping.getRepository();
+		return null;
 	}
 }
-- 
1.5.6.2.220.g44701

  parent reply	other threads:[~2008-07-11 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-10 22:41 [EGIT PATCH 0/2] Quickdiff improvement Robin Rosenberg
2008-07-10 22:41 ` [EGIT PATCH 1/2] Make quick diff aware of changes in the repository Robin Rosenberg
2008-07-10 22:41   ` [EGIT PATCH 2/2] Provide the ability to configure the quickdiff baseline Robin Rosenberg
2008-07-11  5:00     ` Shawn O. Pearce
2008-07-11 21:34   ` Robin Rosenberg [this message]
2008-07-11 21:50     ` EGIT, was Re: [PATCH] Fix nullpointer exceptions in Quickdiff Johannes Schindelin
2008-07-11 22:15       ` Robin Rosenberg

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=200807112334.47552.robin.rosenberg@dewire.com \
    --to=robin.rosenberg@dewire.com \
    --cc=git@vger.kernel.org \
    --cc=marek.zawirski@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.