@@ -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)
@@ -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>
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(+)