Show the correct tree ID in tree views We were incorrectly showing the commit ID (not even the root tree) after "tree:" when viewing a single tree's contents. Change-Id: I88e361fdcc8213089f543db21062769481266c87
diff --git a/gitiles-servlet/src/main/java/com/google/gitiles/PathServlet.java b/gitiles-servlet/src/main/java/com/google/gitiles/PathServlet.java index c929a05..384a589 100644 --- a/gitiles-servlet/src/main/java/com/google/gitiles/PathServlet.java +++ b/gitiles-servlet/src/main/java/com/google/gitiles/PathServlet.java
@@ -118,12 +118,14 @@ TreeWalk tw; FileType type; + ObjectId treeId = null; String path = view.getTreePath(); if (path.isEmpty()) { tw = new TreeWalk(rw.getObjectReader()); tw.addTree(root); tw.setRecursive(false); type = FileType.TREE; + treeId = root; } else { tw = TreeWalk.forPath(rw.getObjectReader(), path, root); if (tw == null) { @@ -132,6 +134,7 @@ } type = FileType.forEntry(tw); if (type == FileType.TREE) { + treeId = tw.getObjectId(0); tw.enterSubtree(); tw.setRecursive(false); } @@ -139,7 +142,7 @@ switch (type) { case TREE: - showTree(req, res, rw, tw, obj); + showTree(req, res, rw, tw, treeId); break; case SYMLINK: showSymlink(req, res, rw, tw);