From patchwork Wed Dec 12 17:10:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CB Bailey X-Patchwork-Id: 10726799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23B096C5 for ; Wed, 12 Dec 2018 17:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CCB72B8A7 for ; Wed, 12 Dec 2018 17:10:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 011D82B8CA; Wed, 12 Dec 2018 17:10:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 994FC2B8A7 for ; Wed, 12 Dec 2018 17:10:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727943AbeLLRKz (ORCPT ); Wed, 12 Dec 2018 12:10:55 -0500 Received: from avasout06.plus.net ([212.159.14.18]:60250 "EHLO avasout06.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727845AbeLLRKz (ORCPT ); Wed, 12 Dec 2018 12:10:55 -0500 Received: from hashpling.plus.com ([212.159.69.125]) by smtp with ESMTP id X829gGsmVuugZX82AgxYB6; Wed, 12 Dec 2018 17:10:54 +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 17:10:52 +0000 Message-Id: <20181212171052.13415-1-cb@hashpling.org> X-Mailer: git-send-email 2.17.0.rc0 In-Reply-To: <20181212164134.12922-1-cb@hashpling.org> References: <20181212164134.12922-1-cb@hashpling.org> X-CMAE-Envelope: MS4wfBzHrdPCI+BMoPLavpgJu78Fqmv6J2l/Qxkfl48P0NSSs5AjT7ZKjv5/qPadfdRhTg1WozBmFSju8Lr9TH+T4824sQyFghkQj0P4Gyx7kssiqsz2WAMx saPgwAkLiJUqObUAGPYfd9fBa+QAzduJA2hz025IcB5V5F9Q2nfUu9XKQsvxptVn/D03KnQw6sNGpw== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: CB Bailey --- Resending with omitted s-o-b. 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