From: James Moger Date: Tue, 27 Nov 2012 22:08:53 +0000 (-0500) Subject: Fixed history page links for files not in the current/active commit (issue 166) X-Git-Tag: v1.2.0~71 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d83bd6d3acfc88a991a08a15dfa3ac36770bb0b8;p=gitblit.git Fixed history page links for files not in the current/active commit (issue 166) --- diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index b83b7142..b9fa3d38 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -12,6 +12,7 @@ The permissions model has changed in this release. #### fixes +- Fixed incorrect links on history page for files not in the current/active commit (issue 166) - Empty repository page failed to handle missing repository (issue 160) - Fixed broken ticgit urls (issue 157) - Exclude submodules from zip downloads (issue 151) diff --git a/src/com/gitblit/wicket/panels/HistoryPanel.java b/src/com/gitblit/wicket/panels/HistoryPanel.java index 14aed912..dee5c25c 100644 --- a/src/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/com/gitblit/wicket/panels/HistoryPanel.java @@ -15,6 +15,7 @@ */ package com.gitblit.wicket.panels; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -26,9 +27,12 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.StringResourceModel; +import org.eclipse.jgit.diff.DiffEntry.ChangeType; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.treewalk.TreeWalk; +import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import com.gitblit.Constants; import com.gitblit.GitBlit; @@ -72,6 +76,26 @@ public class HistoryPanel extends BasePanel { break; } } + if (matchingPath == null) { + // path not in commit + // manually locate path in tree + TreeWalk tw = new TreeWalk(r); + tw.reset(); + tw.setRecursive(true); + try { + tw.addTree(commit.getTree()); + tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path))); + while (tw.next()) { + matchingPath = new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw + .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(), + ChangeType.MODIFY); + } + } catch (Exception e) { + } finally { + tw.release(); + } + } + final boolean isTree = matchingPath == null ? true : matchingPath.isTree(); final Map> allRefs = JGitUtils.getAllRefs(r, showRemoteRefs);