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@xxxxxxxxxx> --- .../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, - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html