Browse Source

RevWalkTextBuiltin: Add -n to limit number of commits returned

Implementing the -<#> flag from C git is less trivial.

Change-Id: Idb55a303304a6d4055aaf37d0b4dcf92c684e25f
stable-3.4
Dave Borowitz 11 years ago
parent
commit
614a477b07
  1. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java

@ -146,6 +146,9 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
revLimiter.add(MessageRevFilter.create(msg));
}
@Option(name = "--max-count", aliases = "-n", metaVar = "metaVar_n")
private int maxCount = -1;
@Override
protected void run() throws Exception {
walk = createWalk();
@ -218,7 +221,8 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
protected int walkLoop() throws Exception {
int n = 0;
for (final RevCommit c : walk) {
n++;
if (++n > maxCount && maxCount >= 0)
break;
show(c);
}
if (walk instanceof ObjectWalk) {

Loading…
Cancel
Save