From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Junio C Hamano <gitster@pobox.com>, Ingo Molnar <mingo@elte.hu>,
Git Mailing List <git@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] shortlog: support --pretty=format: option
Date: Mon, 14 Jul 2008 19:08:52 +0100 (BST) [thread overview]
Message-ID: <alpine.DEB.1.00.0807141907590.8950@racer> (raw)
In-Reply-To: <alpine.DEB.1.00.0807141844160.8950@racer>
With this patch, the user can override the default setting, to print
the commit messages using a user format instead of the onelines of the
commits. Example:
$ git shortlog --pretty='format:%s (%h)' <commit>..
Note that shortlog will only respect a user format setting, as the other
formats do not make much sense.
Wished for by Andrew Morton.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
On Mon, 14 Jul 2008, Johannes Schindelin wrote:
> Note that I do not think it would be all that hard to teach
> shortlog the --pretty option.
Well...
builtin-shortlog.c | 11 +++++++++++
shortlog.h | 1 +
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 0136202..f8bcbfc 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -154,6 +154,15 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
if (!author)
die("Missing author: %s",
sha1_to_hex(commit->object.sha1));
+ if (log->user_format) {
+ struct strbuf buf = STRBUF_INIT;
+
+ pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
+ DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
+ insert_one_record(log, author, buf.buf);
+ strbuf_release(&buf);
+ return;
+ }
if (*buffer)
buffer++;
insert_one_record(log, author, !*buffer ? "<none>" : buffer);
@@ -271,6 +280,8 @@ parse_done:
usage_with_options(shortlog_usage, options);
}
+ log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
+
/* assume HEAD if from a tty */
if (!nongit && !rev.pending.nr && isatty(0))
add_head_to_pending(&rev);
diff --git a/shortlog.h b/shortlog.h
index 31ff491..6608ee8 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -11,6 +11,7 @@ struct shortlog {
int wrap;
int in1;
int in2;
+ int user_format;
char *common_repo_prefix;
int email;
--
1.5.6.2.511.ge432a
next prev parent reply other threads:[~2008-07-14 18:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080714144243.GA21079@elte.hu>
[not found] ` <20080714092215.0efd7fa3.akpm@linux-foundation.org>
[not found] ` <20080714163141.GA21068@elte.hu>
[not found] ` <20080714094422.e7ae255a.akpm@linux-foundation.org>
2008-07-14 17:11 ` [git pull] core/softirq for v2.6.27 Linus Torvalds
2008-07-14 17:23 ` Linus Torvalds
2008-07-14 17:46 ` Johannes Schindelin
2008-07-14 18:08 ` Johannes Schindelin [this message]
2008-07-14 17:46 ` Linus Torvalds
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=alpine.DEB.1.00.0807141907590.8950@racer \
--to=johannes.schindelin@gmx.de \
--cc=akpm@linux-foundation.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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