{"thread":{"id":"52113","subject":"[PATCH v3 0/3] Implement option to output local-part of email addresses","startedAt":"2019-10-24T23:36:30Z","lastAt":"2019-10-25T06:18:31Z","messageCount":7,"participants":["Prarit Bhargava","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"384812","messageId":"20191024233617.18716-1-prarit@redhat.com","threadId":"52113","inReplyTo":null,"subject":"[PATCH v3 0/3] Implement option to output local-part of email addresses","fromName":"Prarit Bhargava","fromEmail":"prarit@redhat.com","sentAt":"2019-10-24T23:36:14Z","receivedAt":"2019-10-24T23:36:30Z","isPatch":true,"sender":{"key":"prarit@redhat.com","avatar":"https://avatars.githubusercontent.com/u/11943259?v=4"},"body":"In many projects the number of contributors is low enough that users know\neach other and the full email address doesn't need to be displayed.\nDisplaying only the author's username saves a lot of columns on the screen.\nFor example displaying \"prarit\" instead of \"prarit@redhat.com\" saves 11\ncolumns.\n\nThe first two patches are clean-up/prep patches that modify tests t6006\nand t4203 to use the definitions in test-lib.sh.  The third patch implements\nthe \"%aL\"|\"%al|%cL|%cl\" pretty options.\n\nSigned-off-by: Prarit Bhargava <prarit@redhat.com>\n\nPrarit Bhargava (3):\n  t6006: Use test-lib.sh definitions\n  t4203: Use test-lib.sh definitions\n  pretty: add \"%aL\"|\"%al|%cL|%cl\" option to output local-part of email\n    addresses\n\n Documentation/pretty-formats.txt |   8 ++\n pretty.c                         |   9 ++-\n t/t4203-mailmap.sh               | 122 +++++++++++++++++++------------\n t/t6006-rev-list-format.sh       |  28 ++++---\n t/test-lib.sh                    |   8 +-\n 5 files changed, 113 insertions(+), 62 deletions(-)\n\n-- \n2.21.0\n\n"},{"id":"384813","messageId":"20191024233617.18716-4-prarit@redhat.com","threadId":"52113","inReplyTo":"20191024233617.18716-1-prarit@redhat.com","subject":"[PATCH v3 3/3] pretty: add \"%aL\"|\"%al|%cL|%cl\" option to output local-part of email addresses","fromName":"Prarit Bhargava","fromEmail":"prarit@redhat.com","sentAt":"2019-10-24T23:36:17Z","receivedAt":"2019-10-24T23:36:32Z","isPatch":true,"sender":{"key":"prarit@redhat.com","avatar":"https://avatars.githubusercontent.com/u/11943259?v=4"},"body":"In many projects the number of contributors is low enough that users know\neach other and the full email address doesn't need to be displayed.\nDisplaying only the author's username saves a lot of columns on the screen.\nFor example displaying \"prarit\" instead of \"prarit@redhat.com\" saves 11\ncolumns.\n\nAdd a \"%aL\"|\"%al|%cL|%cl\" option that output the local-part of an email\naddress.\n\nAlso add tests for \"%ae\",\"%an\", \"%ce\", and \"%cn\".\n\nSigned-off-by: Prarit Bhargava <prarit@redhat.com>\n---\n\nChanges in v2:\n- Changed option to 'L' based on https://www.ietf.org/rfc/rfc2822.txt\n  definition of 'local-part' of email addresses.\n- added additional information to documentation for %cL and %cl\n- added mailmap output test\n- modified code to use mailmap output for \"L\" option\n- modified code to check if email address field has '@' symbol\n- modified tests based on input from Peff\n\nChanges in v3:\n- Adjust Documentation descriptions for %aL and %cL\n- remove exports of TEST* variables from test-lib.sh\n- move testing to t6006 and t4203\n\n Documentation/pretty-formats.txt |  8 ++++++++\n pretty.c                         |  9 ++++++++-\n t/t4203-mailmap.sh               | 28 ++++++++++++++++++++++++++++\n t/t6006-rev-list-format.sh       |  8 ++++++--\n t/test-lib.sh                    |  8 ++++++--\n 5 files changed, 56 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex b87e2e83e6d0..13bac67c446f 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -163,6 +163,10 @@ The placeholders are:\n '%ae':: author email\n '%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1]\n \tor linkgit:git-blame[1])\n+'%al':: author local-part (the portion of the email address preceding the '@'\n+\tsymbol)\n+'%aL':: author local-part (see '%al') respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n '%ad':: author date (format respects --date= option)\n '%aD':: author date, RFC2822 style\n '%ar':: author date, relative\n@@ -175,6 +179,10 @@ The placeholders are:\n '%ce':: committer email\n '%cE':: committer email (respecting .mailmap, see\n \tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%cl':: author local-part (the portion of the email address preceding the '@'\n+\tsymbol)\n+'%cL':: author local-part (see '%cl') respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n '%cd':: committer date (format respects --date= option)\n '%cD':: committer date, RFC2822 style\n '%cr':: committer date, relative\ndiff --git a/pretty.c b/pretty.c\nindex b32f0369531c..93eb6e837071 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -696,7 +696,7 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \tmail = s.mail_begin;\n \tmaillen = s.mail_end - s.mail_begin;\n \n-\tif (part == 'N' || part == 'E') /* mailmap lookup */\n+\tif (part == 'N' || part == 'E' || part == 'L') /* mailmap lookup */\n \t\tmailmap_name(&mail, &maillen, &name, &namelen);\n \tif (part == 'n' || part == 'N') {\t/* name */\n \t\tstrbuf_add(sb, name, namelen);\n@@ -706,6 +706,13 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \t\tstrbuf_add(sb, mail, maillen);\n \t\treturn placeholder_len;\n \t}\n+\tif (part == 'l' || part == 'L') {\t/* local-part */\n+\t\tconst char *at = memchr(mail, '@', maillen);\n+\t\tif (at)\n+\t\t\tmaillen = at - mail;\n+\t\tstrbuf_add(sb, mail, maillen);\n+\t\treturn placeholder_len;\n+\t}\n \n \tif (!s.date_begin)\n \t\tgoto skip;\ndiff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh\nindex e8f9c0f5bc8c..586c3a86b1d2 100755\n--- a/t/t4203-mailmap.sh\n+++ b/t/t4203-mailmap.sh\n@@ -412,6 +412,34 @@ test_expect_success 'Log output (complex mapping)' '\n \ttest_cmp expect actual\n '\n \n+cat >expect << EOF\n+Author email cto@coompany.xx has local-part cto\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+\n+Author email me@company.xx has local-part me\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+\n+Author email me@company.xx has local-part me\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+\n+Author email nick2@company.xx has local-part nick2\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+\n+Author email bugs@company.xx has local-part bugs\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+\n+Author email bugs@company.xx has local-part bugs\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+\n+Author email author@example.com has local-part author\n+Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME\n+EOF\n+\n+test_expect_success 'Log output (local-part email address)' '\n+\tgit log --pretty=format:\"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n cat >expect << EOF\n Author: CTO <cto@company.xx>\n Author: Santa Claus <santa.claus@northpole.xx>\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex 1f7d3f7acc9c..ebdc49c4965e 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -109,31 +109,35 @@ commit $head1\n EOF\n \n # we don't test relative here\n-test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF\n+test_format author %an%n%ae%n%al%n%ad%n%aD%n%at <<EOF\n commit $head2\n $GIT_AUTHOR_NAME\n $GIT_AUTHOR_EMAIL\n+$TEST_AUTHOR_LOCALNAME\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n commit $head1\n $GIT_AUTHOR_NAME\n $GIT_AUTHOR_EMAIL\n+$TEST_AUTHOR_LOCALNAME\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n EOF\n \n-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF\n+test_format committer %cn%n%ce%n%cl%n%cd%n%cD%n%ct <<EOF\n commit $head2\n $GIT_COMMITTER_NAME\n $GIT_COMMITTER_EMAIL\n+$TEST_COMMITTER_LOCALNAME\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n commit $head1\n $GIT_COMMITTER_NAME\n $GIT_COMMITTER_EMAIL\n+$TEST_COMMITTER_LOCALNAME\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex e06fa02a0eec..46c44408432e 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -404,9 +404,13 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $(\"$PERL_PATH\" -e '\n unset XDG_CACHE_HOME\n unset XDG_CONFIG_HOME\n unset GITPERLLIB\n-GIT_AUTHOR_EMAIL=author@example.com\n+TEST_AUTHOR_LOCALNAME=author\n+TEST_AUTHOR_DOMAIN=example.com\n+GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}\n GIT_AUTHOR_NAME='A U Thor'\n-GIT_COMMITTER_EMAIL=committer@example.com\n+TEST_COMMITTER_LOCALNAME=committer\n+TEST_COMMITTER_DOMAIN=example.com\n+GIT_COMMITTER_EMAIL=${TEST_COMMITTER_LOCALNAME}@${TEST_COMMITTER_DOMAIN}\n GIT_COMMITTER_NAME='C O Mitter'\n GIT_MERGE_VERBOSITY=5\n GIT_MERGE_AUTOEDIT=no\n-- \n2.21.0\n\n"},{"id":"384814","messageId":"20191024233617.18716-3-prarit@redhat.com","threadId":"52113","inReplyTo":"20191024233617.18716-1-prarit@redhat.com","subject":"[PATCH v3 2/3] t4203: Use test-lib.sh definitions","fromName":"Prarit Bhargava","fromEmail":"prarit@redhat.com","sentAt":"2019-10-24T23:36:16Z","receivedAt":"2019-10-24T23:36:33Z","isPatch":true,"sender":{"key":"prarit@redhat.com","avatar":"https://avatars.githubusercontent.com/u/11943259?v=4"},"body":"Use name and email definitions from test-lib.sh.\n\nSigned-off-by: Prarit Bhargava <prarit@redhat.com>\n---\n t/t4203-mailmap.sh | 94 +++++++++++++++++++++++-----------------------\n 1 file changed, 47 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh\nindex 918ada69eb96..e8f9c0f5bc8c 100755\n--- a/t/t4203-mailmap.sh\n+++ b/t/t4203-mailmap.sh\n@@ -13,8 +13,8 @@ fuzz_blame () {\n }\n \n test_expect_success setup '\n-\tcat >contacts <<-\\EOF &&\n-\tA U Thor <author@example.com>\n+\tcat >contacts <<- EOF &&\n+\t$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n \tnick1 <bugs@company.xx>\n \tEOF\n \n@@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' '\n '\n \n test_expect_success 'check-mailmap arguments' '\n-\tcat >expect <<-\\EOF &&\n-\tA U Thor <author@example.com>\n+\tcat >expect <<- EOF &&\n+\t$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n \tnick1 <bugs@company.xx>\n \tEOF\n \tgit check-mailmap \\\n-\t\t\"A U Thor <author@example.com>\" \\\n+\t\t\"$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\" \\\n \t\t\"nick1 <bugs@company.xx>\" >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'check-mailmap --stdin' '\n-\tcat >expect <<-\\EOF &&\n-\tA U Thor <author@example.com>\n+\tcat >expect <<- EOF &&\n+\t$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n \tnick1 <bugs@company.xx>\n \tEOF\n \tgit check-mailmap --stdin <contacts >actual &&\n@@ -66,8 +66,8 @@ test_expect_success 'check-mailmap bogus contact' '\n \ttest_must_fail git check-mailmap bogus\n '\n \n-cat >expect <<\\EOF\n-A U Thor (1):\n+cat >expect << EOF\n+$GIT_AUTHOR_NAME (1):\n       initial\n \n nick1 (1):\n@@ -90,7 +90,7 @@ nick1 (1):\n EOF\n \n test_expect_success 'default .mailmap' '\n-\techo \"Repo Guy <author@example.com>\" > .mailmap &&\n+\techo \"Repo Guy <$GIT_AUTHOR_EMAIL>\" > .mailmap &&\n \tgit shortlog HEAD >actual &&\n \ttest_cmp expect actual\n '\n@@ -122,7 +122,7 @@ Internal Guy (1):\n \n EOF\n test_expect_success 'mailmap.file override' '\n-\techo \"External Guy <author@example.com>\" >> internal_mailmap/.mailmap &&\n+\techo \"External Guy <$GIT_AUTHOR_EMAIL>\" >> internal_mailmap/.mailmap &&\n \tgit config mailmap.file internal_mailmap/.mailmap &&\n \tgit shortlog HEAD >actual &&\n \ttest_cmp expect actual\n@@ -178,8 +178,8 @@ test_expect_success 'name entry after email entry, case-insensitive' '\n \ttest_cmp expect actual\n '\n \n-cat >expect <<\\EOF\n-A U Thor (1):\n+cat >expect << EOF\n+$GIT_AUTHOR_NAME (1):\n       initial\n \n nick1 (1):\n@@ -195,18 +195,18 @@ test_expect_success 'No mailmap files, but configured' '\n test_expect_success 'setup mailmap blob tests' '\n \tgit checkout -b map &&\n \ttest_when_finished \"git checkout master\" &&\n-\tcat >just-bugs <<-\\EOF &&\n+\tcat >just-bugs <<- EOF &&\n \tBlob Guy <bugs@company.xx>\n \tEOF\n-\tcat >both <<-\\EOF &&\n-\tBlob Guy <author@example.com>\n+\tcat >both <<- EOF &&\n+\tBlob Guy <$GIT_AUTHOR_EMAIL>\n \tBlob Guy <bugs@company.xx>\n \tEOF\n-\tprintf \"Tricky Guy <author@example.com>\" >no-newline &&\n+\tprintf \"Tricky Guy <$GIT_AUTHOR_EMAIL>\" >no-newline &&\n \tgit add just-bugs both no-newline &&\n \tgit commit -m \"my mailmaps\" &&\n-\techo \"Repo Guy <author@example.com>\" >.mailmap &&\n-\techo \"Internal Guy <author@example.com>\" >internal.map\n+\techo \"Repo Guy <$GIT_AUTHOR_EMAIL>\" >.mailmap &&\n+\techo \"Internal Guy <$GIT_AUTHOR_EMAIL>\" >internal.map\n '\n \n test_expect_success 'mailmap.blob set' '\n@@ -266,12 +266,12 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '\n \tgit init non-bare &&\n \t(\n \t\tcd non-bare &&\n-\t\ttest_commit one .mailmap \"Fake Name <author@example.com>\" &&\n+\t\ttest_commit one .mailmap \"Fake Name <$GIT_AUTHOR_EMAIL>\" &&\n \t\techo \"     1\tFake Name\" >expect &&\n \t\tgit shortlog -ns HEAD >actual &&\n \t\ttest_cmp expect actual &&\n \t\trm .mailmap &&\n-\t\techo \"     1\tA U Thor\" >expect &&\n+\t\techo \"     1\t$GIT_AUTHOR_NAME\" >expect &&\n \t\tgit shortlog -ns HEAD >actual &&\n \t\ttest_cmp expect actual\n \t)\n@@ -305,26 +305,26 @@ test_expect_success 'cleanup after mailmap.blob tests' '\n '\n \n test_expect_success 'single-character name' '\n-\techo \"     1\tA <author@example.com>\" >expect &&\n+\techo \"     1\tA <$GIT_AUTHOR_EMAIL>\" >expect &&\n \techo \"     1\tnick1 <bugs@company.xx>\" >>expect &&\n-\techo \"A <author@example.com>\" >.mailmap &&\n+\techo \"A <$GIT_AUTHOR_EMAIL>\" >.mailmap &&\n \ttest_when_finished \"rm .mailmap\" &&\n \tgit shortlog -es HEAD >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'preserve canonical email case' '\n-\techo \"     1\tA U Thor <AUTHOR@example.com>\" >expect &&\n+\techo \"     1\t$GIT_AUTHOR_NAME <AUTHOR@example.com>\" >expect &&\n \techo \"     1\tnick1 <bugs@company.xx>\" >>expect &&\n-\techo \"<AUTHOR@example.com> <author@example.com>\" >.mailmap &&\n+\techo \"<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>\" >.mailmap &&\n \ttest_when_finished \"rm .mailmap\" &&\n \tgit shortlog -es HEAD >actual &&\n \ttest_cmp expect actual\n '\n \n # Extended mailmap configurations should give us the following output for shortlog\n-cat >expect <<\\EOF\n-A U Thor <author@example.com> (1):\n+cat >expect << EOF\n+$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):\n       initial\n \n CTO <cto@company.xx> (1):\n@@ -370,7 +370,7 @@ test_expect_success 'Shortlog output (complex mapping)' '\n \tgit commit --author \"CTO <cto@coompany.xx>\" -m seventh &&\n \n \tmkdir -p internal_mailmap &&\n-\techo \"Committed <committer@example.com>\" > internal_mailmap/.mailmap &&\n+\techo \"Committed <$GIT_COMMITTER_EMAIL>\" > internal_mailmap/.mailmap &&\n \techo \"<cto@company.xx>                       <cto@coompany.xx>\" >> internal_mailmap/.mailmap &&\n \techo \"Some Dude <some@dude.xx>         nick1 <bugs@company.xx>\" >> internal_mailmap/.mailmap &&\n \techo \"Other Author <other@author.xx>   nick2 <bugs@company.xx>\" >> internal_mailmap/.mailmap &&\n@@ -384,27 +384,27 @@ test_expect_success 'Shortlog output (complex mapping)' '\n '\n \n # git log with --pretty format which uses the name and email mailmap placemarkers\n-cat >expect <<\\EOF\n+cat >expect << EOF\n Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n \n Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n \n Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n \n Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n \n Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n \n Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n \n-Author A U Thor <author@example.com> maps to A U Thor <author@example.com>\n-Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>\n+Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n+Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>\n EOF\n \n test_expect_success 'Log output (complex mapping)' '\n@@ -412,14 +412,14 @@ test_expect_success 'Log output (complex mapping)' '\n \ttest_cmp expect actual\n '\n \n-cat >expect <<\\EOF\n+cat >expect << EOF\n Author: CTO <cto@company.xx>\n Author: Santa Claus <santa.claus@northpole.xx>\n Author: Santa Claus <santa.claus@northpole.xx>\n Author: Other Author <other@author.xx>\n Author: Other Author <other@author.xx>\n Author: Some Dude <some@dude.xx>\n-Author: A U Thor <author@example.com>\n+Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n EOF\n \n test_expect_success 'Log output with --use-mailmap' '\n@@ -427,14 +427,14 @@ test_expect_success 'Log output with --use-mailmap' '\n \ttest_cmp expect actual\n '\n \n-cat >expect <<\\EOF\n+cat >expect << EOF\n Author: CTO <cto@company.xx>\n Author: Santa Claus <santa.claus@northpole.xx>\n Author: Santa Claus <santa.claus@northpole.xx>\n Author: Other Author <other@author.xx>\n Author: Other Author <other@author.xx>\n Author: Some Dude <some@dude.xx>\n-Author: A U Thor <author@example.com>\n+Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n EOF\n \n test_expect_success 'Log output with log.mailmap' '\n@@ -443,28 +443,28 @@ test_expect_success 'Log output with log.mailmap' '\n '\n \n test_expect_success 'log.mailmap=false disables mailmap' '\n-\tcat >expect <<-\\EOF &&\n+\tcat >expect <<- EOF &&\n \tAuthor: CTO <cto@coompany.xx>\n \tAuthor: claus <me@company.xx>\n \tAuthor: santa <me@company.xx>\n \tAuthor: nick2 <nick2@company.xx>\n \tAuthor: nick2 <bugs@company.xx>\n \tAuthor: nick1 <bugs@company.xx>\n-\tAuthor: A U Thor <author@example.com>\n+\tAuthor: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n \tEOF\n \tgit -c log.mailmap=False log | grep Author > actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success '--no-use-mailmap disables mailmap' '\n-\tcat >expect <<-\\EOF &&\n+\tcat >expect <<- EOF &&\n \tAuthor: CTO <cto@coompany.xx>\n \tAuthor: claus <me@company.xx>\n \tAuthor: santa <me@company.xx>\n \tAuthor: nick2 <nick2@company.xx>\n \tAuthor: nick2 <bugs@company.xx>\n \tAuthor: nick1 <bugs@company.xx>\n-\tAuthor: A U Thor <author@example.com>\n+\tAuthor: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n \tEOF\n \tgit log --no-use-mailmap | grep Author > actual &&\n \ttest_cmp expect actual\n@@ -500,8 +500,8 @@ test_expect_success 'Only grep replaced author with --use-mailmap' '\n '\n \n # git blame\n-cat >expect <<\\EOF\n-^OBJI (A U Thor     DATE 1) one\n+cat >expect <<EOF\n+^OBJI ($GIT_AUTHOR_NAME     DATE 1) one\n OBJID (Some Dude    DATE 2) two\n OBJID (Other Author DATE 3) three\n OBJID (Other Author DATE 4) four\n-- \n2.21.0\n\n"},{"id":"384815","messageId":"20191024233617.18716-2-prarit@redhat.com","threadId":"52113","inReplyTo":"20191024233617.18716-1-prarit@redhat.com","subject":"[PATCH v3 1/3] t6006: Use test-lib.sh definitions","fromName":"Prarit Bhargava","fromEmail":"prarit@redhat.com","sentAt":"2019-10-24T23:36:15Z","receivedAt":"2019-10-24T23:36:33Z","isPatch":true,"sender":{"key":"prarit@redhat.com","avatar":"https://avatars.githubusercontent.com/u/11943259?v=4"},"body":"Use name and email definitions from test-lib.sh.\n\nSigned-off-by: Prarit Bhargava <prarit@redhat.com>\n---\n t/t6006-rev-list-format.sh | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh\nindex cfb74d0e0354..1f7d3f7acc9c 100755\n--- a/t/t6006-rev-list-format.sh\n+++ b/t/t6006-rev-list-format.sh\n@@ -111,14 +111,14 @@ EOF\n # we don't test relative here\n test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF\n commit $head2\n-A U Thor\n-author@example.com\n+$GIT_AUTHOR_NAME\n+$GIT_AUTHOR_EMAIL\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n commit $head1\n-A U Thor\n-author@example.com\n+$GIT_AUTHOR_NAME\n+$GIT_AUTHOR_EMAIL\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n@@ -126,14 +126,14 @@ EOF\n \n test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF\n commit $head2\n-C O Mitter\n-committer@example.com\n+$GIT_COMMITTER_NAME\n+$GIT_COMMITTER_EMAIL\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n commit $head1\n-C O Mitter\n-committer@example.com\n+$GIT_COMMITTER_NAME\n+$GIT_COMMITTER_EMAIL\n Thu Apr 7 15:13:13 2005 -0700\n Thu, 7 Apr 2005 15:13:13 -0700\n 1112911993\n@@ -410,7 +410,7 @@ test_expect_success 'empty email' '\n \ttest_tick &&\n \tC=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) &&\n \tA=$(git show --pretty=format:%an,%ae,%ad%n -s $C) &&\n-\tverbose test \"$A\" = \"A U Thor,,Thu Apr 7 15:14:13 2005 -0700\"\n+\tverbose test \"$A\" = \"$GIT_AUTHOR_NAME,,Thu Apr 7 15:14:13 2005 -0700\"\n '\n \n test_expect_success 'del LF before empty (1)' '\n@@ -495,7 +495,7 @@ test_expect_success '%gd shortens ref name' '\n '\n \n test_expect_success 'reflog identity' '\n-\techo \"C O Mitter:committer@example.com\" >expect &&\n+\techo \"$GIT_COMMITTER_NAME:$GIT_COMMITTER_EMAIL\" >expect &&\n \tgit log -g -1 --format=\"%gn:%ge\" >actual &&\n \ttest_cmp expect actual\n '\n-- \n2.21.0\n\n"},{"id":"384844","messageId":"xmqqftjhcqz2.fsf@gitster-ct.c.googlers.com","threadId":"52113","inReplyTo":"20191024233617.18716-4-prarit@redhat.com","subject":"Re: [PATCH v3 3/3] pretty: add \"%aL\"|\"%al|%cL|%cl\" option to output local-part of email addresses","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-25T05:51:45Z","receivedAt":"2019-10-25T05:51:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Prarit Bhargava <prarit@redhat.com> writes:\n\n> Subject: Re: [PATCH v3 3/3] pretty: add \"%aL\"|\"%al|%cL|%cl\" option to output local-part of \n\nThat's somewhat strange paring of quotation marks (the same appears\nlater in the proposed log message).\n\nI'd retitle to\n\n    pretty: add \"%aL\" etc. to show local-part of email addresses\n\nand rewrite this\n\n> Displaying only the author's username saves a lot of columns on the screen.\n> For example displaying \"prarit\" instead of \"prarit@redhat.com\" saves 11\n> columns.\n>\n> Add a \"%aL\"|\"%al|%cL|%cl\" option that output the local-part of an email\n> address.\n\nlike so:\n\n    Existing 'e/E' (as in \"%ae\" and \"%aE\") placeholders would show\n    the author's address as \"prarit@redhat.com\", which would waste\n    columns to show the same domain-part for all contributors when\n    used in redhat-only project.  Introduce 'l/L' placeholders that\n    strip '@' and domain part from the e-mail address.\n\nif I were explaining this patch.\n\n> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> index b87e2e83e6d0..13bac67c446f 100644\n> --- a/Documentation/pretty-formats.txt\n> +++ b/Documentation/pretty-formats.txt\n> @@ -163,6 +163,10 @@ The placeholders are:\n>  '%ae':: author email\n>  '%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1]\n>  \tor linkgit:git-blame[1])\n> +'%al':: author local-part (the portion of the email address preceding the '@'\n> +\tsymbol)\n\nIn a document like RFC2822 that is clearly about e-mail, the phrase\n\"local-part\" alone would be sufficient to convey what we are talking\nabout, but not here.  Let's say \"email local-part\" to qualify.  That\nwould also allow us to shorten the explanation in the parentheses,\nperhaps like so?\n\n    author email local-part (the part before the '@' sign)\n\n> diff --git a/pretty.c b/pretty.c\n> index b32f0369531c..93eb6e837071 100644\n> --- a/pretty.c\n> +++ b/pretty.c\n> @@ -696,7 +696,7 @@ static size_t format_person_part(struct strbuf *sb, char part,\n>  \tmail = s.mail_begin;\n>  \tmaillen = s.mail_end - s.mail_begin;\n>  \n> -\tif (part == 'N' || part == 'E') /* mailmap lookup */\n> +\tif (part == 'N' || part == 'E' || part == 'L') /* mailmap lookup */\n>  \t\tmailmap_name(&mail, &maillen, &name, &namelen);\n>  \tif (part == 'n' || part == 'N') {\t/* name */\n>  \t\tstrbuf_add(sb, name, namelen);\n> @@ -706,6 +706,13 @@ static size_t format_person_part(struct strbuf *sb, char part,\n>  \t\tstrbuf_add(sb, mail, maillen);\n>  \t\treturn placeholder_len;\n>  \t}\n> +\tif (part == 'l' || part == 'L') {\t/* local-part */\n> +\t\tconst char *at = memchr(mail, '@', maillen);\n> +\t\tif (at)\n> +\t\t\tmaillen = at - mail;\n> +\t\tstrbuf_add(sb, mail, maillen);\n> +\t\treturn placeholder_len;\n> +\t}\n\nNicely done.\n\nOverall, looking quite better.\n\nThanks.\n\n"},{"id":"384845","messageId":"xmqqeez1cqbo.fsf@gitster-ct.c.googlers.com","threadId":"52113","inReplyTo":"20191024233617.18716-2-prarit@redhat.com","subject":"Re: [PATCH v3 1/3] t6006: Use test-lib.sh definitions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-25T06:05:47Z","receivedAt":"2019-10-25T06:05:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Prarit Bhargava <prarit@redhat.com> writes:\n\n> Use name and email definitions from test-lib.sh.\n>\n> Signed-off-by: Prarit Bhargava <prarit@redhat.com>\n> ---\n>  t/t6006-rev-list-format.sh | 20 ++++++++++----------\n>  1 file changed, 10 insertions(+), 10 deletions(-)\n\nIt is good to see that you did not go overboard to touch all hits\nin \"git grep -e A.U.Thor -e C.O.Mitt t/\" ;-)\n\nThese look all good.  Thanks.\n"},{"id":"384846","messageId":"xmqq4kzxcpqm.fsf@gitster-ct.c.googlers.com","threadId":"52113","inReplyTo":"20191024233617.18716-3-prarit@redhat.com","subject":"Re: [PATCH v3 2/3] t4203: Use test-lib.sh definitions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-25T06:18:25Z","receivedAt":"2019-10-25T06:18:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Prarit Bhargava <prarit@redhat.com> writes:\n\n> Use name and email definitions from test-lib.sh.\n>\n> Signed-off-by: Prarit Bhargava <prarit@redhat.com>\n> ---\n>  t/t4203-mailmap.sh | 94 +++++++++++++++++++++++-----------------------\n>  1 file changed, 47 insertions(+), 47 deletions(-)\n>\n> diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh\n> index 918ada69eb96..e8f9c0f5bc8c 100755\n> --- a/t/t4203-mailmap.sh\n> +++ b/t/t4203-mailmap.sh\n> @@ -13,8 +13,8 @@ fuzz_blame () {\n>  }\n>  \n>  test_expect_success setup '\n> -\tcat >contacts <<-\\EOF &&\n> -\tA U Thor <author@example.com>\n> +\tcat >contacts <<- EOF &&\n> +\t$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n>  \tnick1 <bugs@company.xx>\n>  \tEOF\n>  \n> @@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' '\n>  '\n>  \n>  test_expect_success 'check-mailmap arguments' '\n> -\tcat >expect <<-\\EOF &&\n> -\tA U Thor <author@example.com>\n> +\tcat >expect <<- EOF &&\n> +\t$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n>  \tnick1 <bugs@company.xx>\n>  \tEOF\n>  \tgit check-mailmap \\\n> -\t\t\"A U Thor <author@example.com>\" \\\n> +\t\t\"$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\" \\\n>  \t\t\"nick1 <bugs@company.xx>\" >actual &&\n>  \ttest_cmp expect actual\n>  '\n>  \n>  test_expect_success 'check-mailmap --stdin' '\n> -\tcat >expect <<-\\EOF &&\n> -\tA U Thor <author@example.com>\n> +\tcat >expect <<- EOF &&\n> +\t$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\n>  \tnick1 <bugs@company.xx>\n>  \tEOF\n>  \tgit check-mailmap --stdin <contacts >actual &&\n\nStrictly speaking, the above is different from the ones that appear\nin the rest of this patch and the ones in step 1/3.\n\nThe reason why you need to expect \"author@example.com\" in the output\nof check-mailmap is only because the same hardcoded string is used\nin the setup step of this test.\n\nThe remainder of this file and step 1/3 are quite different and are\nall good changes.  The commit the data comes from gets created with\nthe value that happens to be set to GIT_AUTHOR_NAME in test-lib---if\nthe assigned value changes over there, the tests that expect\nhardcoded \"author@example.com\" would break, and that makes the step\n1/3 and the remainder of this patch good changes.\n\nIn any case, I think all of 1/3 and 2/3 taken together are good\npreparatory steps for 3/3.\n\nThanks, will queue.\n\n"}]}