diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2010-09-13 09:39:53 +0200 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2010-09-16 10:36:43 +0200 |
commit | 55714f6e73c9f858eb17eadcb9df05de029017aa (patch) | |
tree | e7ad740767b545f313e0e639a54d150b511faa69 /org.eclipse.jgit.pgm | |
parent | 9d14f56442fe02bc3417b26c1211b9f1d0ee476a (diff) | |
download | jgit-55714f6e73c9f858eb17eadcb9df05de029017aa.tar.gz jgit-55714f6e73c9f858eb17eadcb9df05de029017aa.zip |
Add --all option to RevWalkTextBuiltin
Allow our command line commands like Glog, Log to accept the
--all option to walk all known refs.
Change-Id: I6a0c84fc19e7fa80ddaa2315851c58ba89d43ca5
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java | 17 |
1 files changed, 17 insertions, 0 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 bf3924b70b..768890c85c 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 @@ -50,8 +50,10 @@ import java.util.List; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; +import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler; import org.eclipse.jgit.revwalk.FollowFilter; import org.eclipse.jgit.revwalk.ObjectWalk; @@ -80,6 +82,9 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { @Option(name = "--total-count") boolean count = false; + @Option(name = "--all") + boolean all = false; + char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2]; private final EnumSet<RevSort> sorting = EnumSet.noneOf(RevSort.class); @@ -156,6 +161,18 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { else if (revLimiter.size() > 1) walk.setRevFilter(AndRevFilter.create(revLimiter)); + if (all) + for (Ref a : db.getAllRefs().values()) { + ObjectId oid = a.getPeeledObjectId(); + if (oid == null) + oid = a.getObjectId(); + try { + commits.add(walk.parseCommit(oid)); + } catch (IncorrectObjectTypeException e) { + // Ignore all refs which are not commits + } + } + if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) |