summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2008-07-14 18:08:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-15 14:37:00 (GMT)
commitb526f8ed4de646bb914da43b60322852febde758 (patch)
tree80b3064735c65c08d9a8af2833dcd9f1b32e9a32
parent1e5aaa6db38964fd6ca679864c0a40f7af01cf1a (diff)
downloadgit-b526f8ed4de646bb914da43b60322852febde758.zip
git-b526f8ed4de646bb914da43b60322852febde758.tar.gz
git-b526f8ed4de646bb914da43b60322852febde758.tar.bz2
shortlog: support --pretty=format: option
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-shortlog.c11
-rw-r--r--shortlog.h1
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;