Fix IncorrectObjectTypeException on initial commit
On the initial commit of a project, "a" is the empty tree,
not a commit object, in order to show all initial files as
new files. To cast it into a RevTree we must use parseTree()
and not parseCommit().getTree(). For all subsequent changes, "a"
will be a commit and parseTree() will automatically deference to
the commit's root tree.
Bug: issue 442
Change-Id: I9302b6e3d6e9117159e32e96119b6563ac8e26c1
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java
index 71e2ad0..fa75f42 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java
@@ -174,7 +174,7 @@
}
}
- RevTree aTree = a != null ? rw.parseCommit(a).getTree() : null;
+ RevTree aTree = a != null ? rw.parseTree(a) : null;
RevTree bTree = b.getTree();
final int cnt = p.getFiles().size();