From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Jakub Narebski" <jnareb@gmail.com>, "Ted Ts'o" <tytso@mit.edu>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Clemens Buchacher" <drizzd@aon.at>
Subject: [PATCH 4/5] pretty: support %G to show the generation number of a commit
Date: Mon, 11 Jul 2011 12:18:27 -0400 [thread overview]
Message-ID: <20110711161827.GD10418@sigill.intra.peff.net> (raw)
In-Reply-To: <20110711161332.GA10057@sigill.intra.peff.net>
This might be useful for external programs doing topological
sorting or other graph analysis. It's also handy for testing
the generation calculation code.
Signed-off-by: Jeff King <peff@peff.net>
---
Documentation/pretty-formats.txt | 1 +
pretty.c | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 561cc9f..c58ab52 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -133,6 +133,7 @@ The placeholders are:
- '%gD': reflog selector, e.g., `refs/stash@\{1\}`
- '%gd': shortened reflog selector, e.g., `stash@\{1\}`
- '%gs': reflog subject
+- '%G': generation number (i.e., distance of path to farthest root ancestor)
- '%Cred': switch color to red
- '%Cgreen': switch color to green
- '%Cblue': switch color to blue
diff --git a/pretty.c b/pretty.c
index f45eb54..8f1b321 100644
--- a/pretty.c
+++ b/pretty.c
@@ -965,6 +965,9 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
return 2;
}
return 0; /* unknown %g placeholder */
+ case 'G':
+ strbuf_addf(sb, "%lu", commit_generation(commit));
+ return 1;
case 'N':
if (c->pretty_ctx->show_notes) {
format_display_notes(commit->object.sha1, sb,
--
1.7.6.37.g989c6
next prev parent reply other threads:[~2011-07-11 16:18 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-11 16:13 [RFC/PATCH 0/5] generation numbers for faster traversals Jeff King
2011-07-11 16:16 ` [PATCH 1/5] decorate: allow storing values instead of pointers Jeff King
2011-07-11 16:39 ` Jeff King
2011-07-11 19:06 ` Junio C Hamano
2011-07-11 21:20 ` Jeff King
2011-07-11 16:17 ` [PATCH 2/5] add object-cache infrastructure Jeff King
2011-07-11 16:46 ` Jeff King
2011-07-11 16:58 ` Shawn Pearce
2011-07-11 19:17 ` Junio C Hamano
2011-07-11 22:01 ` Jeff King
2011-07-11 23:21 ` Junio C Hamano
2011-07-11 23:42 ` Junio C Hamano
2011-07-12 0:03 ` Jeff King
2011-07-12 19:38 ` Clemens Buchacher
2011-07-12 19:45 ` Jeff King
2011-07-12 21:07 ` Clemens Buchacher
2011-07-12 21:15 ` Clemens Buchacher
2011-07-12 21:36 ` Jeff King
2011-07-14 8:04 ` Clemens Buchacher
2011-07-14 16:26 ` Illia Bobyr
2011-07-13 1:33 ` John Szakmeister
2011-07-12 0:14 ` Illia Bobyr
2011-07-12 5:35 ` Jeff King
2011-07-12 21:52 ` Illia Bobyr
2011-07-12 6:36 ` Miles Bader
2011-07-12 10:41 ` Jakub Narebski
2011-07-12 17:57 ` Jeff King
2011-07-12 18:41 ` Junio C Hamano
2011-07-13 6:37 ` Jeff King
2011-07-13 17:49 ` Junio C Hamano
2011-07-11 16:18 ` [PATCH 3/5] commit: add commit_generation function Jeff King
2011-07-11 17:57 ` Clemens Buchacher
2011-07-11 21:10 ` Jeff King
2011-07-11 16:18 ` Jeff King [this message]
2011-07-11 16:18 ` [PATCH 5/5] limit "contains" traversals based on commit generation Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110711161827.GD10418@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=avarab@gmail.com \
--cc=drizzd@aon.at \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=jrnieder@gmail.com \
--cc=tytso@mit.edu \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).