From: Alexander Shishkin <ash@koowaldah.org>
To: git@vger.kernel.org
Cc: Alexander Shishkin <ash@koowaldah.org>
Subject: [PATCH/RFC] pretty.c: add %O format specifier to format_commit_one()
Date: Sat, 1 May 2010 13:56:41 +0300 [thread overview]
Message-ID: <1272711401-29005-1-git-send-email-ash@koowaldah.org> (raw)
This specifier represents the number of each commit in the output
stream.
Signed-off-by: Alexander Shishkin <ash@koowaldah.org>
---
Documentation/pretty-formats.txt | 3 ++-
pretty.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 1686a54..7b0cab1 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -137,7 +137,8 @@ The placeholders are:
- '%%': a raw '%'
- '%x00': print a byte from a hex code
- '%w([<w>[,<i1>[,<i2>]]])': switch line wrapping, like the -w option of
- linkgit:git-shortlog[1].
+ linkgit:git-shortlog[1]
+- '%O': number of the record in the output.
NOTE: Some placeholders may depend on other options given to the
revision traversal engine. For example, the `%g*` reflog options will
diff --git a/pretty.c b/pretty.c
index 7cb3a2a..3e3d399 100644
--- a/pretty.c
+++ b/pretty.c
@@ -11,6 +11,7 @@
#include "reflog-walk.h"
static char *user_format;
+static int record_number;
static void save_user_format(struct rev_info *rev, const char *cp, int is_tformat)
{
@@ -639,6 +640,9 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
/* these are independent of the commit */
switch (placeholder[0]) {
+ case 'O':
+ strbuf_addf(sb, "%d", record_number);
+ return 1;
case 'C':
if (placeholder[1] == '(') {
const char *end = strchr(placeholder + 2, ')');
@@ -899,6 +903,7 @@ void format_commit_message(const struct commit *commit,
context.wrap_start = sb->len;
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
+ record_number++;
}
static void pp_header(enum cmit_fmt fmt,
--
1.7.0.4
next reply other threads:[~2010-05-01 11:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-01 10:56 Alexander Shishkin [this message]
2010-05-01 17:18 ` [PATCH/RFC] pretty.c: add %O format specifier to format_commit_one() Junio C Hamano
2010-05-01 17:56 ` Alexander Shishkin
2010-05-01 19:39 ` Jakub Narebski
2010-05-02 4:55 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1272711401-29005-1-git-send-email-ash@koowaldah.org \
--to=ash@koowaldah.org \
--cc=git@vger.kernel.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).