From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id DDFC620A1E for ; Wed, 12 Dec 2018 16:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728142AbeLLQtI (ORCPT ); Wed, 12 Dec 2018 11:49:08 -0500 Received: from avasout06.plus.net ([212.159.14.18]:57708 "EHLO avasout06.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbeLLQtH (ORCPT ); Wed, 12 Dec 2018 11:49:07 -0500 X-Greylist: delayed 451 seconds by postgrey-1.27 at vger.kernel.org; Wed, 12 Dec 2018 11:49:07 EST Received: from hashpling.plus.com ([212.159.69.125]) by smtp with ESMTP id X7ZmgGp1guugZX7ZngxVa7; Wed, 12 Dec 2018 16:41:36 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=bLE43s2Z c=1 sm=1 tr=0 a=wpJ/2au8Z6V/NgdivHIBow==:117 a=wpJ/2au8Z6V/NgdivHIBow==:17 a=BNFp--SqAAAA:8 a=A1X0JdhQAAAA:8 a=gZhEERMA3JooW-Zfbv0A:9 a=wCHOS_8tIzIYXQCUOVd6:22 a=Df3jFdWbhGDLdZNm0fyq:22 From: CB Bailey To: git@vger.kernel.org Subject: [PATCH] shortlog: pass the mailmap into the revision walker Date: Wed, 12 Dec 2018 16:41:34 +0000 Message-Id: <20181212164134.12922-1-cb@hashpling.org> X-Mailer: git-send-email 2.17.0.rc0 X-CMAE-Envelope: MS4wfOET4RS8hi7hMLzDRZyyRAOgK85/BcRJwquMYDkdLn7f6WV10l2u5lG6EzTiZJIltEtpupr0DQdQiJaxwDuxJMZ1Oqwvs2sAVz/ofGT+MXTmjboU+idU jj8Yh3ZoyAuLpnOEzSkBVZpJNJB9FtBwTV6BU+2HMNneYB52Tq473R8+nKLZQTwRUSmLVzNT6KmyXg== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: CB Bailey 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 \n" >expect && + + git shortlog -es --author="A U Thor" HEAD >actual && + test_cmp expect actual && + + printf " 1\tCTO \n" >expect && + + git shortlog -es --author=CTO HEAD >actual && + test_cmp expect actual && + + printf " 2\tOther Author \n" >expect && + + git shortlog -es --author="Other Author" HEAD >actual && + test_cmp expect actual && + + printf " 2\tSanta Claus \n" >expect && + + git shortlog -es --author="Santa Claus" HEAD >actual && + test_cmp expect actual && + + printf " 1\tSome Dude \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 maps to CTO -- 2.17.0.rc0