git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: spearce@spearce.org
Cc: git@vger.kernel.org
Subject: [EGIT PATCH 07/10] Return nothing if no version exists for a commit.
Date: Sun, 11 Mar 2007 19:15:53 +0100	[thread overview]
Message-ID: <20070311181553.18012.62004.stgit@lathund.dewire.com> (raw)
In-Reply-To: <20070311180608.18012.13767.stgit@lathund.dewire.com>

I used a null reference to mean two things, which meant the
working directory version was retrieved for comparing files
when a commit did not include a named blob.

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

 .../src/org/spearce/egit/core/GitStorage.java      |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java b/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java
index e53fd83..ce4ff71 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java
@@ -41,7 +41,10 @@ public class GitStorage implements IStorage {
 
 	private TreeEntry entry;
 
+	private ObjectId treeId;
+
 	public GitStorage(ObjectId treeId, IResource resource) {
+		this.treeId = treeId;
 		this.resource = resource;
 		if (treeId == null)
 			return;
@@ -68,13 +71,17 @@ public class GitStorage implements IStorage {
 
 	public InputStream getContents() throws CoreException {
 		try {
-			if (entry == null) {
+			if (treeId == null) {
 				return ((IFile) resource).getContents();
 			} else {
-				ObjectId id = entry.getId();
-				ObjectLoader reader = entry.getRepository().openBlob(id);
-				byte[] bytes = reader.getBytes();
-				return new ByteArrayInputStream(bytes);
+				if (entry == null)
+					return new ByteArrayInputStream(new byte[0]);
+				else {
+					ObjectId id = entry.getId();
+					ObjectLoader reader = entry.getRepository().openBlob(id);
+					byte[] bytes = reader.getBytes();
+					return new ByteArrayInputStream(bytes);
+				}
 			}
 		} catch (FileNotFoundException e) {
 			throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL,

  parent reply	other threads:[~2007-03-11 18:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 18:15 [EGIT PATCH 00/10] Fixes and improvement on Eclipse plugin Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 01/10] Git history refresh problem Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 02/10] Support commit encoding header Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 03/10] Avoid a nullpointerexception on shutdown Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 04/10] Speed up history by comparing tree hashes Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 05/10] Cache commits Robin Rosenberg
2007-03-11 18:15 ` [EGIT PATCH 06/10] Allow history listing on folders and projects Robin Rosenberg
2007-03-11 18:15 ` Robin Rosenberg [this message]
2007-03-11 18:15 ` [EGIT PATCH 08/10] Show only commits that represent changes in the history view Robin Rosenberg
2007-03-11 18:16 ` [EGIT PATCH 09/10] Hash ObjectId faster Robin Rosenberg
2007-03-11 18:16 ` [EGIT PATCH 10/10] Display distance to head in history page Robin Rosenberg
2007-03-11 20:11 ` [PATCH 0/2] Series short description Robin Rosenberg
2007-03-11 20:19   ` Shawn O. Pearce
2007-03-11 20:45     ` Robin Rosenberg
2007-03-11 20:11 ` [PATCH 1/2] Tag version 0.2.1 Robin Rosenberg
2007-03-11 20:11 ` [PATCH 2/2] Re-add qualfiier for development version 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=20070311181553.18012.62004.stgit@lathund.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).