From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 1/1] Allow "git shortlog" to group by committer information
Date: Thu, 15 Dec 2016 17:45:14 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.20.1612151741280.3583@i7> (raw)
In-Reply-To: <xmqqoa0cu3nn.fsf@gitster.mtv.corp.google.com>
From: Linus Torvalds <torvalds@linux-foundation.org>
Subject: Allow "git shortlog" to group by committer information
Date: Tue, 11 Oct 2016 11:45:58 -0700
In some situations you may want to group the commits not by author, but by
committer instead.
For example, when I just wanted to look up what I'm still missing from
linux-next in the current merge window, I don't care so much about who
wrote a patch, as what git tree it came from, which generally boils down
to "who committed it".
So make git shortlog take a "-c" or "--committer" option to switch
grouping to that. During the merge window this allows me to do things like
git shortlog -cnse linus..next |
head -20 |
cut -f2 |
sed 's/$/,/'
to easily create a list of the top-20 committers that I haven't gotten
pull requests from yet (the committer is not necessarily the person who
will send the pull request, but it's a reasonably good approximation).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
builtin/shortlog.c | 15 ++++++++++++---
shortlog.h | 1 +
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index ba0e1154a..c9585d475 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -117,11 +117,15 @@ static void read_from_stdin(struct shortlog *log)
{
struct strbuf author = STRBUF_INIT;
struct strbuf oneline = STRBUF_INIT;
+ static const char *author_match[2] = { "Author: ", "author " };
+ static const char *committer_match[2] = { "Commit: ", "committer " };
+ const char **match;
+ match = log->committer ? committer_match : author_match;
while (strbuf_getline_lf(&author, stdin) != EOF) {
const char *v;
- if (!skip_prefix(author.buf, "Author: ", &v) &&
- !skip_prefix(author.buf, "author ", &v))
+ if (!skip_prefix(author.buf, match[0], &v) &&
+ !skip_prefix(author.buf, match[1], &v))
continue;
while (strbuf_getline_lf(&oneline, stdin) != EOF &&
oneline.len)
@@ -140,6 +144,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
struct strbuf author = STRBUF_INIT;
struct strbuf oneline = STRBUF_INIT;
struct pretty_print_context ctx = {0};
+ const char *fmt;
ctx.fmt = CMIT_FMT_USERFORMAT;
ctx.abbrev = log->abbrev;
@@ -148,7 +153,9 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
ctx.date_mode.type = DATE_NORMAL;
ctx.output_encoding = get_log_output_encoding();
- format_commit_message(commit, "%an <%ae>", &author, &ctx);
+ fmt = log->committer ? "%cn <%ce>" : "%an <%ae>";
+
+ format_commit_message(commit, fmt, &author, &ctx);
if (!log->summary) {
if (log->user_format)
pretty_print_commit(&ctx, commit, &oneline);
@@ -238,6 +245,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
int nongit = !startup_info->have_repository;
const struct option options[] = {
+ OPT_BOOL('c', "committer", &log.committer,
+ N_("Group by committer rather than author")),
OPT_BOOL('n', "numbered", &log.sort_by_number,
N_("sort output according to the number of commits per author")),
OPT_BOOL('s', "summary", &log.summary,
diff --git a/shortlog.h b/shortlog.h
index 5a326c686..5d64cfe92 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -13,6 +13,7 @@ struct shortlog {
int in2;
int user_format;
int abbrev;
+ int committer;
char *common_repo_prefix;
int email;
next prev parent reply other threads:[~2016-12-16 1:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 18:45 Allow "git shortlog" to group by committer information Linus Torvalds
2016-10-11 19:01 ` Jeff King
2016-10-11 19:07 ` Linus Torvalds
2016-10-11 19:17 ` Jeff King
2016-12-15 21:29 ` Linus Torvalds
2016-12-16 0:19 ` Junio C Hamano
2016-12-16 1:39 ` Linus Torvalds
2016-12-16 4:56 ` Junio C Hamano
2016-12-16 1:45 ` Linus Torvalds [this message]
2016-12-16 1:51 ` Stephen & Linda Smith
2016-12-16 2:00 ` Linus Torvalds
2016-12-16 13:39 ` Jeff King
2016-12-16 13:51 ` Jeff King
2016-12-16 17:27 ` Junio C Hamano
2016-12-20 18:12 ` Johannes Sixt
2016-12-20 18:19 ` Junio C Hamano
2016-12-20 18:24 ` Junio C Hamano
2016-12-20 18:35 ` Junio C Hamano
2016-12-20 18:52 ` Johannes Sixt
2016-12-21 21:09 ` Johannes Sixt
2016-12-21 3:22 ` Jeff King
2016-12-21 7:55 ` Jacob Keller
2016-12-21 16:04 ` Jeff King
2016-12-21 20:44 ` Junio C Hamano
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=alpine.LFD.2.20.1612151741280.3583@i7 \
--to=torvalds@linux-foundation.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).