aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
index 632b5d0e30..21a0d342a9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
@@ -59,7 +59,9 @@ import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.revwalk.filter.AndRevFilter;
import org.eclipse.jgit.revwalk.filter.MaxCountRevFilter;
+import org.eclipse.jgit.revwalk.filter.SkipRevFilter;
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
import org.eclipse.jgit.treewalk.filter.PathFilter;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
@@ -88,6 +90,8 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
private int maxCount = -1;
+ private int skip = -1;
+
/**
* @param repo
*/
@@ -111,7 +115,12 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
if (pathFilters.size() > 0)
walk.setTreeFilter(AndTreeFilter.create(
PathFilterGroup.create(pathFilters), TreeFilter.ANY_DIFF));
- if (maxCount > -1)
+ if (skip > -1 && maxCount > -1)
+ walk.setRevFilter(AndRevFilter.create(SkipRevFilter.create(skip),
+ MaxCountRevFilter.create(maxCount)));
+ else if (skip > -1)
+ walk.setRevFilter(SkipRevFilter.create(skip));
+ else if (maxCount > -1)
walk.setRevFilter(MaxCountRevFilter.create(maxCount));
if (!startSpecified) {
try {
@@ -253,7 +262,20 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
}
/**
- * Limit the number of commits to output
+ * Skip the number of commits before starting to show the commit output.
+ *
+ * @param skip
+ * the number of commits to skip
+ * @return {@code this}
+ */
+ public LogCommand setSkip(int skip) {
+ checkCallable();
+ this.skip = skip;
+ return this;
+ }
+
+ /**
+ * Limit the number of commits to output.
*
* @param maxCount
* the limit