[EGIT PATCH 07/10] Return nothing if no version exists for a commit.
- From
Robin Rosenberg <robin.rosenberg@dewire.com>
- Date
- Mar 11, 2007, 18:15 UTC
- Message-ID
- <20070311181553.18012.62004.stgit@lathund.dewire.com>
- 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,