Implement option to output local-part of email addresses
v3 cover Implement option to output local-part of email addresses
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 "[email protected]" saves 11 columns.
The first two patches are clean-up/prep patches that modify tests t6006 and t4203 to use the definitions in test-lib.sh. The third patch implements the "%aL"|"%al|%cL|%cl" pretty options.
Prarit Bhargava (3):
t6006: Use test-lib.sh definitions
t4203: Use test-lib.sh definitions
pretty: add "%aL"|"%al|%cL|%cl" option to output local-part of email
addresses
Documentation/pretty-formats.txt | 8 ++ pretty.c | 9 ++- t/t4203-mailmap.sh | 122 +++++++++++++++++++------------ t/t6006-rev-list-format.sh | 28 ++++--- t/test-lib.sh | 8 +- 5 files changed, 113 insertions(+), 62 deletions(-)
Signature · 1 line
2.21.0
PATCH v3 1/3 t6006: Use test-lib.sh definitions
Use name and email definitions from test-lib.sh.
--- t/t6006-rev-list-format.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
t/t6006-rev-list-format.sh +10 -10
@@ -111,14 +111,14 @@ EOF # we don't test relative here test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF commit $head2 -A U Thor [email protected] +$GIT_AUTHOR_NAME +$GIT_AUTHOR_EMAIL Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993 commit $head1 -A U Thor [email protected] +$GIT_AUTHOR_NAME +$GIT_AUTHOR_EMAIL Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993
@@ -126,14 +126,14 @@ EOF test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF commit $head2 -C O Mitter [email protected] +$GIT_COMMITTER_NAME +$GIT_COMMITTER_EMAIL Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993 commit $head1 -C O Mitter [email protected] +$GIT_COMMITTER_NAME +$GIT_COMMITTER_EMAIL Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993
@@ -410,7 +410,7 @@ test_expect_success 'empty email' ' test_tick && C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) && A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) && - verbose test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" + verbose test "$A" = "$GIT_AUTHOR_NAME,,Thu Apr 7 15:14:13 2005 -0700" ' test_expect_success 'del LF before empty (1)' '
@@ -495,7 +495,7 @@ test_expect_success '%gd shortens ref name' ' ' test_expect_success 'reflog identity' ' - echo "C O Mitter:[email protected]" >expect && + echo "$GIT_COMMITTER_NAME:$GIT_COMMITTER_EMAIL" >expect && git log -g -1 --format="%gn:%ge" >actual && test_cmp expect actual '
Signature · 1 line
2.21.0
Re: [PATCH v3 1/3] t6006: Use test-lib.sh definitions
Quoted 6 lines · Prarit Bhargava
Use name and email definitions from
test-lib.sh.Signed-off-by Prarit Bhargava <[email protected]>--- t/t6006-rev-list-format.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
It is good to see that you did not go overboard to touch all hits in "git grep -e A.U.Thor -e C.O.Mitt t/" ;-)
These look all good. Thanks.
PATCH v3 2/3 t4203: Use test-lib.sh definitions
In reply to Prarit BhargavaUse name and email definitions from test-lib.sh.
--- t/t4203-mailmap.sh | 94 +++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-)
t/t4203-mailmap.sh +47 -47
@@ -13,8 +13,8 @@ fuzz_blame () { } test_expect_success setup ' - cat >contacts <<-\EOF && - A U Thor <[email protected]> + cat >contacts <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <[email protected]> EOF
@@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' ' ' test_expect_success 'check-mailmap arguments' ' - cat >expect <<-\EOF && - A U Thor <[email protected]> + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <[email protected]> EOF git check-mailmap \ - "A U Thor <[email protected]>" \ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" \ "nick1 <[email protected]>" >actual && test_cmp expect actual ' test_expect_success 'check-mailmap --stdin' ' - cat >expect <<-\EOF && - A U Thor <[email protected]> + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <[email protected]> EOF git check-mailmap --stdin <contacts >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 <[email protected]>" > .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 <[email protected]>" >> 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 <[email protected]> EOF - cat >both <<-\EOF && - Blob Guy <[email protected]> + cat >both <<- EOF && + Blob Guy <$GIT_AUTHOR_EMAIL> Blob Guy <[email protected]> EOF - printf "Tricky Guy <[email protected]>" >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 <[email protected]>" >.mailmap && - echo "Internal Guy <[email protected]>" >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 <[email protected]>" && + 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 <[email protected]>" >expect && + echo " 1 A <$GIT_AUTHOR_EMAIL>" >expect && echo " 1 nick1 <[email protected]>" >>expect && - echo "A <[email protected]>" >.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 <[email protected]>" >expect && + echo " 1 $GIT_AUTHOR_NAME <[email protected]>" >expect && echo " 1 nick1 <[email protected]>" >>expect && - echo "<[email protected]> <[email protected]>" >.mailmap && + echo "<[email protected]> <$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 <[email protected]> (1): +cat >expect << EOF +$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1): initial CTO <[email protected]> (1):
@@ -370,7 +370,7 @@ test_expect_success 'Shortlog output (complex mapping)' ' git commit --author "CTO <[email protected]>" -m seventh && mkdir -p internal_mailmap && - echo "Committed <[email protected]>" > internal_mailmap/.mailmap && + echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap && echo "<[email protected]> <[email protected]>" >> internal_mailmap/.mailmap && echo "Some Dude <[email protected]> nick1 <[email protected]>" >> internal_mailmap/.mailmap && echo "Other Author <[email protected]> nick2 <[email protected]>" >> 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 <[email protected]> maps to CTO <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author claus <[email protected]> maps to Santa Claus <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author santa <[email protected]> maps to Santa Claus <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick2 <[email protected]> maps to Other Author <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick2 <[email protected]> maps to Other Author <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> Author nick1 <[email protected]> maps to Some Dude <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL> -Author A U Thor <[email protected]> maps to A U Thor <[email protected]> -Committer C O Mitter <[email protected]> maps to Committed <[email protected]> +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 <[email protected]> Author: Santa Claus <[email protected]> Author: Santa Claus <[email protected]> Author: Other Author <[email protected]> Author: Other Author <[email protected]> Author: Some Dude <[email protected]> -Author: A U Thor <[email protected]> +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 <[email protected]> Author: Santa Claus <[email protected]> Author: Santa Claus <[email protected]> Author: Other Author <[email protected]> Author: Other Author <[email protected]> Author: Some Dude <[email protected]> -Author: A U Thor <[email protected]> +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 <[email protected]> Author: claus <[email protected]> Author: santa <[email protected]> Author: nick2 <[email protected]> Author: nick2 <[email protected]> Author: nick1 <[email protected]> - Author: A U Thor <[email protected]> + 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 <[email protected]> Author: claus <[email protected]> Author: santa <[email protected]> Author: nick2 <[email protected]> Author: nick2 <[email protected]> Author: nick1 <[email protected]> - Author: A U Thor <[email protected]> + 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 <<EOF +^OBJI ($GIT_AUTHOR_NAME DATE 1) one OBJID (Some Dude DATE 2) two OBJID (Other Author DATE 3) three OBJID (Other Author DATE 4) four
Signature · 1 line
2.21.0
Re: [PATCH v3 2/3] t4203: Use test-lib.sh definitions
Quoted 37 lines · Prarit Bhargava
Use name and email definitions from
test-lib.sh.Signed-off-by Prarit Bhargava <[email protected]>--- t/t4203-mailmap.sh | 94 +++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-)t/t4203-mailmap.sh +5
-5@@ -13,8 +13,8 @@ fuzz_blame () { } test_expect_success setup ' - cat >contacts <<-\EOF && - A U Thor <[email protected]> + cat >contacts <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <[email protected]> EOF@@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' ' ' test_expect_success 'check-mailmap arguments' ' - cat >expect <<-\EOF && - A U Thor <[email protected]> + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <[email protected]> EOF git check-mailmap \ - "A U Thor <[email protected]>" \ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" \ "nick1 <[email protected]>" >actual && test_cmp expect actual
t/t4203-mailmap.sh test_expect_success 'check-mailmap no arguments' ' · line 51
Quoted 10 lines
t/t4203-mailmap.sh +2
-2' test_expect_success 'check-mailmap --stdin' ' - cat >expect <<-\EOF && - A U Thor <[email protected]> + cat >expect <<- EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <[email protected]> EOF git check-mailmap --stdin <contacts >actual &&
Strictly speaking, the above is different from the ones that appear in the rest of this patch and the ones in step 1/3.
The reason why you need to expect "[email protected]" in the output of check-mailmap is only because the same hardcoded string is used in the setup step of this test.
The remainder of this file and step 1/3 are quite different and are all good changes. The commit the data comes from gets created with the value that happens to be set to GIT_AUTHOR_NAME in test-lib---if the assigned value changes over there, the tests that expect hardcoded "[email protected]" would break, and that makes the step 1/3 and the remainder of this patch good changes.
In any case, I think all of 1/3 and 2/3 taken together are good preparatory steps for 3/3.
Thanks, will queue.
PATCH v3 3/3 pretty: add "%aL"|"%al|%cL|%cl" option to output local-part of email addresses
In reply to Prarit BhargavaIn 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 "[email protected]" 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".
---
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(-)
Documentation/pretty-formats.txt +8 -0
@@ -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
pretty.c +8 -1
@@ -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;
t/t4203-mailmap.sh +28 -0
@@ -412,6 +412,34 @@ test_expect_success 'Log output (complex mapping)' ' test_cmp expect actual ' +cat >expect << EOF +Author email [email protected] has local-part cto +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email [email protected] has local-part me +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email [email protected] has local-part me +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email [email protected] has local-part nick2 +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email [email protected] has local-part bugs +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email [email protected] has local-part bugs +Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME + +Author email [email protected] 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 <[email protected]> Author: Santa Claus <[email protected]>
t/t6006-rev-list-format.sh +6 -2
@@ -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 <<EOF +test_format author %an%n%ae%n%al%n%ad%n%aD%n%at <<EOF commit $head2 $GIT_AUTHOR_NAME $GIT_AUTHOR_EMAIL +$TEST_AUTHOR_LOCALNAME Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993 commit $head1 $GIT_AUTHOR_NAME $GIT_AUTHOR_EMAIL +$TEST_AUTHOR_LOCALNAME Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993 EOF -test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF +test_format committer %cn%n%ce%n%cl%n%cd%n%cD%n%ct <<EOF commit $head2 $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL +$TEST_COMMITTER_LOCALNAME Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993 commit $head1 $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL +$TEST_COMMITTER_LOCALNAME Thu Apr 7 15:13:13 2005 -0700 Thu, 7 Apr 2005 15:13:13 -0700 1112911993
t/test-lib.sh +6 -2
@@ -404,9 +404,13 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e ' unset XDG_CACHE_HOME unset XDG_CONFIG_HOME unset GITPERLLIB [email protected] +TEST_AUTHOR_LOCALNAME=author +TEST_AUTHOR_DOMAIN=example.com +GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN} GIT_AUTHOR_NAME='A U Thor' [email protected] +TEST_COMMITTER_LOCALNAME=committer +TEST_COMMITTER_DOMAIN=example.com +GIT_COMMITTER_EMAIL=${TEST_COMMITTER_LOCALNAME}@${TEST_COMMITTER_DOMAIN} GIT_COMMITTER_NAME='C O Mitter' GIT_MERGE_VERBOSITY=5 GIT_MERGE_AUTOEDIT=no
Signature · 1 line
2.21.0
Re: [PATCH v3 3/3] pretty: add "%aL"|"%al|%cL|%cl" option to output local-part of email addresses
Quoted 1 line · Prarit Bhargava
Subject: Re: [PATCH v3 3/3] pretty: add "%aL"|"%al|%cL|%cl" option to output local-part of
That's somewhat strange paring of quotation marks (the same appears later in the proposed log message).
I'd retitle to
pretty: add "%aL" etc. to show local-part of email addresses
and rewrite this
Quoted 6 lines
Displaying only the author's username saves a lot of columns on the screen. For example displaying "prarit" instead of "[email protected]" saves 11 columns.
Add a "%aL"|"%al|%cL|%cl" option that output the local-part of an email address.
like so:
Existing 'e/E' (as in "%ae" and "%aE") placeholders would show the author's address as "[email protected]", which would waste columns to show the same domain-part for all contributors when used in redhat-only project. Introduce 'l/L' placeholders that strip '@' and domain part from the e-mail address.
if I were explaining this patch.
Documentation/pretty-formats.txt The placeholders are: · line 167
Quoted 10 lines
Documentation/pretty-formats.txt +2
-0@@ -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)
In a document like RFC2822 that is clearly about e-mail, the phrase "local-part" alone would be sufficient to convey what we are talking about, but not here. Let's say "email local-part" to qualify. That would also allow us to shorten the explanation in the parentheses, perhaps like so?
author email local-part (the part before the '@' sign)
Quoted 14 lines
pretty.c +1
-1@@ -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);
pretty.c static size_t format_person_part(struct strbuf *sb, char part, · line 715
Quoted 10 lines
pretty.c +7
-0@@ -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; + }
Nicely done.
Overall, looking quite better.
Thanks.