diff options
author | Dave Borowitz <dborowitz@google.com> | 2014-05-05 12:42:23 -0700 |
---|---|---|
committer | Dave Borowitz <dborowitz@google.com> | 2014-05-05 15:58:33 -0700 |
commit | 614a477b079412d05762808b7ab0d014cf05e80f (patch) | |
tree | 17fbabbf07c3c0a371af6443789d659417094c92 /org.eclipse.jgit.pgm/src/org/eclipse | |
parent | f6c42684d9af1355cecdd5f83fbf216718980ab9 (diff) | |
download | jgit-614a477b079412d05762808b7ab0d014cf05e80f.tar.gz jgit-614a477b079412d05762808b7ab0d014cf05e80f.zip |
RevWalkTextBuiltin: Add -n to limit number of commits returned
Implementing the -<#> flag from C git is less trivial.
Change-Id: Idb55a303304a6d4055aaf37d0b4dcf92c684e25f
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java index e23fb356af..94156aa7e4 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java +++ b/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) { |