From 01bd346efe98af0f05f23f897c0819d2df8d856c Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Sat, 16 Apr 2011 16:47:14 -0400 Subject: [PATCH] Replaced three history placeholder labels with real links. --- src/com/gitblit/utils/JGitUtils.java | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 69c46da..7128f72 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -35,6 +35,7 @@ import org.eclipse.jgit.revwalk.RevTree; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.treewalk.TreeWalk; +import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.PathFilter; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -340,11 +341,11 @@ } return null; } - + public static String getCommitPatch(Repository r, RevCommit commit) { return getCommitPatch(r, commit); } - + public static String getCommitPatch(Repository r, RevCommit commit, String path) { try { final RevWalk rw = new RevWalk(r); @@ -436,6 +437,10 @@ } public static List<RevCommit> getRevLog(Repository r, String objectId, int offset, int maxCount) { + return getRevLog(r, objectId, null, offset, maxCount); + } + + public static List<RevCommit> getRevLog(Repository r, String objectId, String path, int offset, int maxCount) { List<RevCommit> list = new ArrayList<RevCommit>(); try { if (objectId == null || objectId.trim().length() == 0) { @@ -444,6 +449,12 @@ RevWalk walk = new RevWalk(r); ObjectId object = r.resolve(objectId); walk.markStart(walk.parseCommit(object)); + if (!StringUtils.isEmpty(path)) { + TreeFilter filter = AndTreeFilter.create(PathFilterGroup + .createFromStrings(Collections.singleton(path)), + TreeFilter.ANY_DIFF); + walk.setTreeFilter(filter); + } Iterable<RevCommit> revlog = walk; if (offset > 0) { int count = 0; -- Gitblit v1.9.1