From: CB Bailey <cb@hashpling.org>
To: git@vger.kernel.org
Subject: [PATCH] shortlog: pass the mailmap into the revision walker
Date: Wed, 12 Dec 2018 16:41:34 +0000 [thread overview]
Message-ID: <20181212164134.12922-1-cb@hashpling.org> (raw)
From: CB Bailey <cbailey32@bloomberg.net>
shortlog always respects the mailmap in its output. Pass the mailmap
into the revision walker to allow the mailmap to be used with revision
limiting options such as '--author'.
This removes some apparently inconsistent behaviors when using
'--author', such as not finding some or all commits for a given author
which do appear under that author in an unrestricted invocation of
shortlog or commits being summarized under a different author than the
specified author.
---
builtin/shortlog.c | 2 ++
t/t4203-mailmap.sh | 28 ++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 88f88e97b2..a6fb00ade8 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -188,6 +188,8 @@ static void get_from_rev(struct rev_info *rev, struct shortlog *log)
{
struct commit *commit;
+ rev->mailmap = &log->mailmap;
+
if (prepare_revision_walk(rev))
die(_("revision walk setup failed"));
while ((commit = get_revision(rev)) != NULL)
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 43b1522ea2..9bee35b06c 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -383,6 +383,34 @@ test_expect_success 'Shortlog output (complex mapping)' '
'
+test_expect_success 'Shortlog output (complex mapping, filtered)' '
+
+ printf " 1\tA U Thor <author@example.com>\n" >expect &&
+
+ git shortlog -es --author="A U Thor" HEAD >actual &&
+ test_cmp expect actual &&
+
+ printf " 1\tCTO <cto@company.xx>\n" >expect &&
+
+ git shortlog -es --author=CTO HEAD >actual &&
+ test_cmp expect actual &&
+
+ printf " 2\tOther Author <other@author.xx>\n" >expect &&
+
+ git shortlog -es --author="Other Author" HEAD >actual &&
+ test_cmp expect actual &&
+
+ printf " 2\tSanta Claus <santa.claus@northpole.xx>\n" >expect &&
+
+ git shortlog -es --author="Santa Claus" HEAD >actual &&
+ test_cmp expect actual &&
+
+ printf " 1\tSome Dude <some@dude.xx>\n" >expect &&
+
+ git shortlog -es --author="Some Dude" HEAD >actual &&
+ test_cmp expect actual
+'
+
# git log with --pretty format which uses the name and email mailmap placemarkers
cat >expect <<\EOF
Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
--
2.17.0.rc0
next reply other threads:[~2018-12-12 16:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 16:41 CB Bailey [this message]
2018-12-12 17:10 ` [PATCH] shortlog: pass the mailmap into the revision walker CB Bailey
2018-12-12 18:31 ` Ævar Arnfjörð Bjarmason
2018-12-12 19:19 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181212164134.12922-1-cb@hashpling.org \
--to=cb@hashpling.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.