提交 b526f8ed 编写于 作者: J Johannes Schindelin 提交者: Junio C Hamano

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: NJohannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 1e5aaa6d
...@@ -154,6 +154,15 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit) ...@@ -154,6 +154,15 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
if (!author) if (!author)
die("Missing author: %s", die("Missing author: %s",
sha1_to_hex(commit->object.sha1)); 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) if (*buffer)
buffer++; buffer++;
insert_one_record(log, author, !*buffer ? "<none>" : buffer); insert_one_record(log, author, !*buffer ? "<none>" : buffer);
...@@ -271,6 +280,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) ...@@ -271,6 +280,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
usage_with_options(shortlog_usage, options); usage_with_options(shortlog_usage, options);
} }
log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
/* assume HEAD if from a tty */ /* assume HEAD if from a tty */
if (!nongit && !rev.pending.nr && isatty(0)) if (!nongit && !rev.pending.nr && isatty(0))
add_head_to_pending(&rev); add_head_to_pending(&rev);
......
...@@ -11,6 +11,7 @@ struct shortlog { ...@@ -11,6 +11,7 @@ struct shortlog {
int wrap; int wrap;
int in1; int in1;
int in2; int in2;
int user_format;
char *common_repo_prefix; char *common_repo_prefix;
int email; int email;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册