]> source.dussan.org Git - gitblit.git/commitdiff
Fixed history page links for files not in the current/active commit (issue 166)
authorJames Moger <james.moger@gitblit.com>
Tue, 27 Nov 2012 22:08:53 +0000 (17:08 -0500)
committerJames Moger <james.moger@gitblit.com>
Tue, 27 Nov 2012 22:08:53 +0000 (17:08 -0500)
docs/04_releases.mkd
src/com/gitblit/wicket/panels/HistoryPanel.java

index b83b714270b77a828d5a091285fd240b6026425d..b9fa3d38d6f813081cfa385a3554965ba7645967 100644 (file)
@@ -12,6 +12,7 @@ The permissions model has changed in this release.
 \r
 #### fixes\r
 \r
+- Fixed incorrect links on history page for files not in the current/active commit (issue 166)\r
 - Empty repository page failed to handle missing repository (issue 160)\r
 - Fixed broken ticgit urls (issue 157)\r
 - Exclude submodules from zip downloads (issue 151)\r
index 14aed9121781755e453537a14de820d70e2c893e..dee5c25c1aca7d52c83a727c48b0bcb419e521ec 100644 (file)
@@ -15,6 +15,7 @@
  */\r
 package com.gitblit.wicket.panels;\r
 \r
+import java.util.Collections;\r
 import java.util.Date;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -26,9 +27,12 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.apache.wicket.model.StringResourceModel;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.lib.ObjectId;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
+import org.eclipse.jgit.treewalk.TreeWalk;\r
+import org.eclipse.jgit.treewalk.filter.PathFilterGroup;\r
 \r
 import com.gitblit.Constants;\r
 import com.gitblit.GitBlit;\r
@@ -72,6 +76,26 @@ public class HistoryPanel extends BasePanel {
                                break;\r
                        }\r
                }\r
+               if (matchingPath == null) {\r
+                       // path not in commit\r
+                       // manually locate path in tree\r
+                       TreeWalk tw = new TreeWalk(r);\r
+                       tw.reset();\r
+                       tw.setRecursive(true);\r
+                       try {\r
+                               tw.addTree(commit.getTree());\r
+                               tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));\r
+                               while (tw.next()) {\r
+                                       matchingPath = new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw\r
+                                                       .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(),\r
+                                                       ChangeType.MODIFY);\r
+                               }\r
+                       } catch (Exception e) {\r
+                       } finally {\r
+                               tw.release();\r
+                       }\r
+               }\r
+               \r
                final boolean isTree = matchingPath == null ? true : matchingPath.isTree();\r
 \r
                final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r, showRemoteRefs);\r