Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- .../src/org/spearce/jgit/pgm/Log.java | 33 ++++++++++++++++++++ 1 files changed, 33 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 e3a32c8..bb424d4 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,11 +40,19 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Iterator; import java.util.Locale; +import java.util.Map; +import java.util.Set; 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 { @@ -52,14 +60,39 @@ private final DateFormat fmt; + private Map<AnyObjectId, Set<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", Locale.US); } @Override + protected 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) { + Collection<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.3.578.g6a50 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html