From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: git@vger.kernel.org
Cc: spearce@spearce.org, Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [EGIT PATCH 5/6] Add decorate option to log program
Date: Mon, 6 Oct 2008 01:36:41 +0200 [thread overview]
Message-ID: <1223249802-9959-6-git-send-email-robin.rosenberg@dewire.com> (raw)
In-Reply-To: <1223249802-9959-5-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/pgm/Log.java | 32 ++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Log.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Log.java
index e16387b..378d9e0 100644
--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Log.java
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Log.java
@@ -40,10 +40,17 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.TimeZone;
+import org.kohsuke.args4j.Option;
+import org.spearce.jgit.lib.AnyObjectId;
import org.spearce.jgit.lib.PersonIdent;
+import org.spearce.jgit.lib.Ref;
import org.spearce.jgit.revwalk.RevCommit;
+import org.spearce.jgit.revwalk.RevWalk;
@Command(common = true, usage = "View commit history")
class Log extends RevWalkTextBuiltin {
@@ -51,14 +58,39 @@
private final DateFormat fmt;
+ private Map<AnyObjectId, List<Ref>> allRefsByPeeledObjectId;
+
+ @Option(name="--decorate", usage="Show ref names matching commits")
+ private boolean decorate;
+
Log() {
fmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy ZZZZZ");
}
@Override
+ protected org.spearce.jgit.revwalk.RevWalk createWalk() {
+ RevWalk ret = super.createWalk();
+ if (decorate)
+ allRefsByPeeledObjectId = getRepository().getAllRefsByPeeledObjectId();
+ return ret;
+ }
+
+ @Override
protected void show(final RevCommit c) throws Exception {
out.print("commit ");
c.getId().copyTo(outbuffer, out);
+ if (decorate) {
+ List<Ref> list = allRefsByPeeledObjectId.get(c.copy());
+ if (list != null) {
+ out.print(" (");
+ for (Iterator<Ref> i = list.iterator(); i.hasNext(); ) {
+ out.print(i.next().getOrigName());
+ if (i.hasNext())
+ out.print(" ");
+ }
+ out.print(")");
+ }
+ }
out.println();
final PersonIdent author = c.getAuthorIdent();
--
1.6.0.1.310.gf789d0.dirty
next prev parent reply other threads:[~2008-10-05 23:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-05 23:36 (unknown), Robin Rosenberg
2008-10-05 23:36 ` [EGIT PATCH 1/6] Keep original ref name when reading refs Robin Rosenberg
2008-10-05 23:36 ` [EGIT PATCH 2/6] Peel annotated tags when getting all refs Robin Rosenberg
2008-10-05 23:36 ` [EGIT PATCH 3/6] Add a method to get refs by object Id Robin Rosenberg
2008-10-05 23:36 ` [EGIT PATCH 4/6] Add tags to the graphical history display Robin Rosenberg
2008-10-05 23:36 ` Robin Rosenberg [this message]
2008-10-05 23:36 ` [EGIT PATCH 6/6] Comment the getId method and hint for copy to actually get an ObjectId Robin Rosenberg
2008-10-06 8:08 ` [EGIT PATCH 4/6] Add tags to the graphical history display Shawn O. Pearce
2008-10-06 21:58 ` Robin Rosenberg
2008-10-06 22:14 ` Shawn O. Pearce
2008-10-06 8:15 ` [EGIT PATCH 3/6] Add a method to get refs by object Id Shawn O. Pearce
2008-10-06 22:37 ` Robin Rosenberg
2008-10-06 22:43 ` Shawn O. Pearce
2008-10-06 7:43 ` [EGIT PATCH 2/6] Peel annotated tags when getting all refs Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1223249802-9959-6-git-send-email-robin.rosenberg@dewire.com \
--to=robin.rosenberg@dewire.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).