From patchwork Thu Oct 24 23:36:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 11211161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8C101575 for ; Thu, 24 Oct 2019 23:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86A9720650 for ; Thu, 24 Oct 2019 23:36:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RJDXMaH/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732498AbfJXXgc (ORCPT ); Thu, 24 Oct 2019 19:36:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29143 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727309AbfJXXga (ORCPT ); Thu, 24 Oct 2019 19:36:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571960189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Rbfjg8jjKhKxyMZMnQVoQJtkdX2yyeBQxAgO1sYJ/Q=; b=RJDXMaH/fsGWC95ACwvOMmuV/n1FFRJIGJEu5Am/A0MO0uR1B57nsp5UAAIEAJDYOF6S/A HNrk+L2g7Wf0e/MU5NcnZhbNm1pXFywSKUXvv5f1P6ExgCml97iGHkaNUo2SaG0RZjp/22 lE6sBW4GDYqsRZ993uVIw0rYRhjeDno= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-tL8KllvmMoCoQ3c32Wd5gw-1; Thu, 24 Oct 2019 19:36:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38B481800D6B; Thu, 24 Oct 2019 23:36:24 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76467600C6; Thu, 24 Oct 2019 23:36:23 +0000 (UTC) From: Prarit Bhargava To: git@vger.kernel.org Cc: gitster@pobox.com, sandals@crustytoothpaste.net, peff@peff.net, szeder.dev@gmail.com, Prarit Bhargava Subject: [PATCH v3 1/3] t6006: Use test-lib.sh definitions Date: Thu, 24 Oct 2019 19:36:15 -0400 Message-Id: <20191024233617.18716-2-prarit@redhat.com> In-Reply-To: <20191024233617.18716-1-prarit@redhat.com> References: <20191024233617.18716-1-prarit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: tL8KllvmMoCoQ3c32Wd5gw-1 X-Mimecast-Spam-Score: 0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Use name and email definitions from test-lib.sh. Signed-off-by: Prarit Bhargava --- t/t6006-rev-list-format.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index cfb74d0e0354..1f7d3f7acc9c 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -111,14 +111,14 @@ EOF # we don't test relative here test_format author %an%n%ae%n%ad%n%aD%n%at <expect && + echo "$GIT_COMMITTER_NAME:$GIT_COMMITTER_EMAIL" >expect && git log -g -1 --format="%gn:%ge" >actual && test_cmp expect actual ' From patchwork Thu Oct 24 23:36:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 11211159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CCB41920 for ; Thu, 24 Oct 2019 23:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47A8720650 for ; Thu, 24 Oct 2019 23:36:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UYlEMPYU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732412AbfJXXgb (ORCPT ); Thu, 24 Oct 2019 19:36:31 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31358 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732305AbfJXXga (ORCPT ); Thu, 24 Oct 2019 19:36:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571960189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z/dRfvcKyRiSx6sur9HPxhHXoOsrIQRsMz+gqbKC7K4=; b=UYlEMPYUwXOVNezOfLw2cRrEs2+15KKQCE9xQc2TM3foHz0VDv7hoaul8tPIbmDGmKTVbu eEj8mJEMHmQqAQOdJLTEK6ZzAF29bbOfMVoewnIgOGVHaCQPXNbaZIlLaeAv51xGDywwHn Nou9iT2KiX+vOQSrofwXytqRzvUzixw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-qj0bbrdmOIOBpJSY4WrP9A-1; Thu, 24 Oct 2019 19:36:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17691476; Thu, 24 Oct 2019 23:36:25 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 539BE600C6; Thu, 24 Oct 2019 23:36:24 +0000 (UTC) From: Prarit Bhargava To: git@vger.kernel.org Cc: gitster@pobox.com, sandals@crustytoothpaste.net, peff@peff.net, szeder.dev@gmail.com, Prarit Bhargava Subject: [PATCH v3 2/3] t4203: Use test-lib.sh definitions Date: Thu, 24 Oct 2019 19:36:16 -0400 Message-Id: <20191024233617.18716-3-prarit@redhat.com> In-Reply-To: <20191024233617.18716-1-prarit@redhat.com> References: <20191024233617.18716-1-prarit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: qj0bbrdmOIOBpJSY4WrP9A-1 X-Mimecast-Spam-Score: 0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Use name and email definitions from test-lib.sh. Signed-off-by: Prarit Bhargava --- t/t4203-mailmap.sh | 94 +++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 918ada69eb96..e8f9c0f5bc8c 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -13,8 +13,8 @@ fuzz_blame () { } test_expect_success setup ' - cat >contacts <<-\EOF && - A U Thor + cat >contacts <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 EOF @@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' ' ' test_expect_success 'check-mailmap arguments' ' - cat >expect <<-\EOF && - A U Thor + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 EOF git check-mailmap \ - "A U Thor " \ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" \ "nick1 " >actual && test_cmp expect actual ' test_expect_success 'check-mailmap --stdin' ' - cat >expect <<-\EOF && - A U Thor + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 EOF git check-mailmap --stdin actual && @@ -66,8 +66,8 @@ test_expect_success 'check-mailmap bogus contact' ' test_must_fail git check-mailmap bogus ' -cat >expect <<\EOF -A U Thor (1): +cat >expect << EOF +$GIT_AUTHOR_NAME (1): initial nick1 (1): @@ -90,7 +90,7 @@ nick1 (1): EOF test_expect_success 'default .mailmap' ' - echo "Repo Guy " > .mailmap && + echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap && git shortlog HEAD >actual && test_cmp expect actual ' @@ -122,7 +122,7 @@ Internal Guy (1): EOF test_expect_success 'mailmap.file override' ' - echo "External Guy " >> internal_mailmap/.mailmap && + echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap && git config mailmap.file internal_mailmap/.mailmap && git shortlog HEAD >actual && test_cmp expect actual @@ -178,8 +178,8 @@ test_expect_success 'name entry after email entry, case-insensitive' ' test_cmp expect actual ' -cat >expect <<\EOF -A U Thor (1): +cat >expect << EOF +$GIT_AUTHOR_NAME (1): initial nick1 (1): @@ -195,18 +195,18 @@ test_expect_success 'No mailmap files, but configured' ' test_expect_success 'setup mailmap blob tests' ' git checkout -b map && test_when_finished "git checkout master" && - cat >just-bugs <<-\EOF && + cat >just-bugs <<- EOF && Blob Guy EOF - cat >both <<-\EOF && - Blob Guy + cat >both <<- EOF && + Blob Guy <$GIT_AUTHOR_EMAIL> Blob Guy EOF - printf "Tricky Guy " >no-newline && + printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline && git add just-bugs both no-newline && git commit -m "my mailmaps" && - echo "Repo Guy " >.mailmap && - echo "Internal Guy " >internal.map + echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap && + echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map ' test_expect_success 'mailmap.blob set' ' @@ -266,12 +266,12 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' ' git init non-bare && ( cd non-bare && - test_commit one .mailmap "Fake Name " && + test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" && echo " 1 Fake Name" >expect && git shortlog -ns HEAD >actual && test_cmp expect actual && rm .mailmap && - echo " 1 A U Thor" >expect && + echo " 1 $GIT_AUTHOR_NAME" >expect && git shortlog -ns HEAD >actual && test_cmp expect actual ) @@ -305,26 +305,26 @@ test_expect_success 'cleanup after mailmap.blob tests' ' ' test_expect_success 'single-character name' ' - echo " 1 A " >expect && + echo " 1 A <$GIT_AUTHOR_EMAIL>" >expect && echo " 1 nick1 " >>expect && - echo "A " >.mailmap && + echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap && test_when_finished "rm .mailmap" && git shortlog -es HEAD >actual && test_cmp expect actual ' test_expect_success 'preserve canonical email case' ' - echo " 1 A U Thor " >expect && + echo " 1 $GIT_AUTHOR_NAME " >expect && echo " 1 nick1 " >>expect && - echo " " >.mailmap && + echo " <$GIT_AUTHOR_EMAIL>" >.mailmap && test_when_finished "rm .mailmap" && git shortlog -es HEAD >actual && test_cmp expect actual ' # Extended mailmap configurations should give us the following output for shortlog -cat >expect <<\EOF -A U Thor (1): +cat >expect << EOF +$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1): initial CTO (1): @@ -370,7 +370,7 @@ test_expect_success 'Shortlog output (complex mapping)' ' git commit --author "CTO " -m seventh && mkdir -p internal_mailmap && - echo "Committed " > internal_mailmap/.mailmap && + echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap && echo " " >> internal_mailmap/.mailmap && echo "Some Dude nick1 " >> internal_mailmap/.mailmap && echo "Other Author nick2 " >> internal_mailmap/.mailmap && @@ -384,27 +384,27 @@ test_expect_success 'Shortlog output (complex mapping)' ' ' # git log with --pretty format which uses the name and email mailmap placemarkers -cat >expect <<\EOF +cat >expect << EOF Author CTO maps to CTO -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author claus maps to Santa Claus -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author santa maps to Santa Claus -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick2 maps to Other Author -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick2 maps to Other Author -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick1 maps to Some Dude -Committer C O Mitter maps to Committed +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author A U Thor maps to A U Thor -Committer C O Mitter maps to Committed +Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> EOF test_expect_success 'Log output (complex mapping)' ' @@ -412,14 +412,14 @@ test_expect_success 'Log output (complex mapping)' ' test_cmp expect actual ' -cat >expect <<\EOF +cat >expect << EOF Author: CTO Author: Santa Claus Author: Santa Claus Author: Other Author Author: Other Author Author: Some Dude -Author: A U Thor +Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF test_expect_success 'Log output with --use-mailmap' ' @@ -427,14 +427,14 @@ test_expect_success 'Log output with --use-mailmap' ' test_cmp expect actual ' -cat >expect <<\EOF +cat >expect << EOF Author: CTO Author: Santa Claus Author: Santa Claus Author: Other Author Author: Other Author Author: Some Dude -Author: A U Thor +Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF test_expect_success 'Log output with log.mailmap' ' @@ -443,28 +443,28 @@ test_expect_success 'Log output with log.mailmap' ' ' test_expect_success 'log.mailmap=false disables mailmap' ' - cat >expect <<-\EOF && + cat >expect <<- EOF && Author: CTO Author: claus Author: santa Author: nick2 Author: nick2 Author: nick1 - Author: A U Thor + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF git -c log.mailmap=False log | grep Author > actual && test_cmp expect actual ' test_expect_success '--no-use-mailmap disables mailmap' ' - cat >expect <<-\EOF && + cat >expect <<- EOF && Author: CTO Author: claus Author: santa Author: nick2 Author: nick2 Author: nick1 - Author: A U Thor + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> EOF git log --no-use-mailmap | grep Author > actual && test_cmp expect actual @@ -500,8 +500,8 @@ test_expect_success 'Only grep replaced author with --use-mailmap' ' ' # git blame -cat >expect <<\EOF -^OBJI (A U Thor DATE 1) one +cat >expect < X-Patchwork-Id: 11211157 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D99C1864 for ; Thu, 24 Oct 2019 23:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1303121D71 for ; Thu, 24 Oct 2019 23:36:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V6YMDDJv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732420AbfJXXgb (ORCPT ); Thu, 24 Oct 2019 19:36:31 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48894 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732318AbfJXXga (ORCPT ); Thu, 24 Oct 2019 19:36:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571960189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mCo7bsueaO5Cc9mGkKl2PKxv5002roDAwnxvhTCyaiY=; b=V6YMDDJvXXQCcK9lm4ZQ9qRw/Kv+H2dZy2/oJ8CuBUEJVKmA3xlaNOTPKGKSe/HdpA/T8O dMu9bFbyqfHp9iecg/5/I6fKY/kRBn24FoYnzySS+raQEVNoBVbgIi7BXg97Zuq/gwd4UF BQjRrauL7eMOyVa2Hw3uM9nfpTFKIU4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-lv6BABSVPsWlI_V0x1ydtw-1; Thu, 24 Oct 2019 19:36:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E43831800E04; Thu, 24 Oct 2019 23:36:25 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BAB7600C6; Thu, 24 Oct 2019 23:36:25 +0000 (UTC) From: Prarit Bhargava To: git@vger.kernel.org Cc: gitster@pobox.com, sandals@crustytoothpaste.net, peff@peff.net, szeder.dev@gmail.com, Prarit Bhargava Subject: [PATCH v3 3/3] pretty: add "%aL"|"%al|%cL|%cl" option to output local-part of email addresses Date: Thu, 24 Oct 2019 19:36:17 -0400 Message-Id: <20191024233617.18716-4-prarit@redhat.com> In-Reply-To: <20191024233617.18716-1-prarit@redhat.com> References: <20191024233617.18716-1-prarit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: lv6BABSVPsWlI_V0x1ydtw-1 X-Mimecast-Spam-Score: 0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In many projects the number of contributors is low enough that users know each other and the full email address doesn't need to be displayed. Displaying only the author's username saves a lot of columns on the screen. For example displaying "prarit" instead of "prarit@redhat.com" saves 11 columns. Add a "%aL"|"%al|%cL|%cl" option that output the local-part of an email address. Also add tests for "%ae","%an", "%ce", and "%cn". Signed-off-by: Prarit Bhargava --- Changes in v2: - Changed option to 'L' based on https://www.ietf.org/rfc/rfc2822.txt definition of 'local-part' of email addresses. - added additional information to documentation for %cL and %cl - added mailmap output test - modified code to use mailmap output for "L" option - modified code to check if email address field has '@' symbol - modified tests based on input from Peff Changes in v3: - Adjust Documentation descriptions for %aL and %cL - remove exports of TEST* variables from test-lib.sh - move testing to t6006 and t4203 Documentation/pretty-formats.txt | 8 ++++++++ pretty.c | 9 ++++++++- t/t4203-mailmap.sh | 28 ++++++++++++++++++++++++++++ t/t6006-rev-list-format.sh | 8 ++++++-- t/test-lib.sh | 8 ++++++-- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index b87e2e83e6d0..13bac67c446f 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -163,6 +163,10 @@ The placeholders are: '%ae':: author email '%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%al':: author local-part (the portion of the email address preceding the '@' + symbol) +'%aL':: author local-part (see '%al') respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) '%ad':: author date (format respects --date= option) '%aD':: author date, RFC2822 style '%ar':: author date, relative @@ -175,6 +179,10 @@ The placeholders are: '%ce':: committer email '%cE':: committer email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%cl':: author local-part (the portion of the email address preceding the '@' + symbol) +'%cL':: author local-part (see '%cl') respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) '%cd':: committer date (format respects --date= option) '%cD':: committer date, RFC2822 style '%cr':: committer date, relative diff --git a/pretty.c b/pretty.c index b32f0369531c..93eb6e837071 100644 --- a/pretty.c +++ b/pretty.c @@ -696,7 +696,7 @@ static size_t format_person_part(struct strbuf *sb, char part, mail = s.mail_begin; maillen = s.mail_end - s.mail_begin; - if (part == 'N' || part == 'E') /* mailmap lookup */ + if (part == 'N' || part == 'E' || part == 'L') /* mailmap lookup */ mailmap_name(&mail, &maillen, &name, &namelen); if (part == 'n' || part == 'N') { /* name */ strbuf_add(sb, name, namelen); @@ -706,6 +706,13 @@ static size_t format_person_part(struct strbuf *sb, char part, strbuf_add(sb, mail, maillen); return placeholder_len; } + if (part == 'l' || part == 'L') { /* local-part */ + const char *at = memchr(mail, '@', maillen); + if (at) + maillen = at - mail; + strbuf_add(sb, mail, maillen); + return placeholder_len; + } if (!s.date_begin) goto skip; diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index e8f9c0f5bc8c..586c3a86b1d2 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -412,6 +412,34 @@ test_expect_success 'Log output (complex mapping)' ' test_cmp expect actual ' +cat >expect << EOF +Author email cto@coompany.xx has local-part cto +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email me@company.xx has local-part me +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email me@company.xx has local-part me +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email nick2@company.xx has local-part nick2 +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email bugs@company.xx has local-part bugs +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email bugs@company.xx has local-part bugs +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email author@example.com has local-part author +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME +EOF + +test_expect_success 'Log output (local-part email address)' ' + git log --pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n" >actual && + test_cmp expect actual +' + cat >expect << EOF Author: CTO Author: Santa Claus diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index 1f7d3f7acc9c..ebdc49c4965e 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -109,31 +109,35 @@ commit $head1 EOF # we don't test relative here -test_format author %an%n%ae%n%ad%n%aD%n%at <