-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shortlog: introduce
--email-only
to only show emails
When a shortlog caller wants to group output by, say, author email, they can easily express this with: $ git shortlog --group=format:%ae and restrict output to specific email(s) with the new `--group-filter` option introduced by the previous commit. But they are not able to apply the same treatment to identities that appear in trailers. Doing: $ git shortlog -e --group=format:%ae --group=trailer:Co-authored-by will produce funky results, interspersing proper emails with full "Name <email>" identities from the Co-authored-by trailer (or anything else that might appear there), like: 461 [email protected] 11 Taylor Blau <[email protected]> So if the caller wants to restrict output to a set of matching email addresses (say, "[email protected]"), they cannot do it with a `--group-filter`, since it would discard the group "Taylor Blau <[email protected]>". Introduce a new `--email-only` option, which extracts the email component of an identity from all shortlog groups, including trailers. It behaves similarly to the `-e` option, but replaces its output with just the email component, instead of adding it on to the end. Now, `shortlog` callers can perform: $ git shortlog -s --group=author --group=trailer:Co-authored-by \ --email-only --group-filter="<[email protected]>" 472 <[email protected]> to obtain the output they want. Signed-off-by: Taylor Blau <[email protected]>
- Loading branch information
Showing
4 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,6 +400,34 @@ test_expect_success '--no-group-filter reset group filters' ' | |
test_cmp expect actual | ||
' | ||
|
||
test_expect_success '--email-only shows emails from author' ' | ||
cat >expect <<-\EOF && | ||
2 <[email protected]> | ||
EOF | ||
git shortlog -ns --group=author --email-only -2 HEAD >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success '--email-only shows emails from committer' ' | ||
cat >expect <<-\EOF && | ||
2 <[email protected]> | ||
EOF | ||
git shortlog -ns --group=committer --email-only -2 HEAD >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success '--email-only shows emails from trailers with idents' ' | ||
cat >expect <<-\EOF && | ||
1 <[email protected]> | ||
1 <[email protected]> | ||
EOF | ||
# at this point, HEAD~3 has a trailer "Repeated-trailer: Foo", | ||
# which is not shown here since it cannot be parsed as an ident | ||
git shortlog -ns --group=trailer:some-trailer --email-only -3 \ | ||
HEAD >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'shortlog can match multiple format groups' ' | ||
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" \ | ||
git commit --allow-empty -m "identical names" && | ||
|