* [PATCH v2] git-send-email: fix --cc-cmd get_maintainer.pl regression
@ 2017-11-20 11:44 Alex Bennée
0 siblings, 0 replies; only message in thread
From: Alex Bennée @ 2017-11-20 11:44 UTC (permalink / raw)
To: git; +Cc: Alex Bennée, Eric Sunshine
Since the removal of Mail::Address from git-send-email certain address
patterns returned by common get_maintainer.pl scripts now fail to get
correctly parsed by the built-in Git::parse_mailboxes. Specifically
the patterns with embedded parenthesis fail. For example from the
Linux kernel MAINTAINERS:
KERNEL VIRTUAL MACHINE FOR ARM (KVM/arm)
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
L: kvmarm@lists.cs.columbia.edu
Which is returned by get_maintainers.pl as:
linux-arm-kernel@lists.infradead.org (moderated list:KERNEL VIRTUAL MACHINE FOR ARM (KVM/arm))
kvmarm@lists.cs.columbia.edu (open list:KERNEL VIRTUAL MACHINE FOR ARM (KVM/arm))
However Git::parse_mailboxes code mangles the address, appending the
trailing parenthesis to the email address to the address part causing
it to fail validation:
error: unable to extract a valid address from: linux-arm-kernel@lists.infradead.org) (moderated list:KERNEL VIRTUAL MACHINE FOR ARM (KVM/arm)
error: unable to extract a valid address from: kvmarm@lists.cs.columbia.edu) (open list:KERNEL VIRTUAL MACHINE FOR ARM (KVM/arm)
As this is a common pattern which was handled by Mail::Address I've
fixed the regression by explicitly capturing a trailing bracket and
appending it to the comment token.
NB: the t9001.sh test doesn't explicitly wrap the call to the --cc-cmd
in a "$(pwd)/expected-cc-script.sh" which fails due to the space to
the full-path of the test. It is currently ambiguous as to if --cc-cmd
needs to handle this. I suspect it is not an edge case that has come
up in real-world usage as git-send-email is usually run directly from
a git directory with scripts generally in a ./script/get_maintainer.pl
path.
Fixes: cc9075067776ebd34cc08f31bf78bb05f12fd879
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Eric Sunshine <sunshine@sunshineco.com>
---
perl/Git.pm | 3 +++
t/t9000/test.pl | 3 ++-
t/t9001-send-email.sh | 16 ++++++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index ffa09ace9..9b17de1cc 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -936,6 +936,9 @@ sub parse_mailboxes {
$end_of_addr_seen = 0;
} elsif ($token =~ /^\(/) {
push @comment, $token;
+ } elsif ($token =~ /^\)/) {
+ my $nested_comment = pop @comment;
+ push @comment, "$nested_comment$token";
} elsif ($token eq "<") {
push @phrase, (splice @address), (splice @buffer);
} elsif ($token eq ">") {
diff --git a/t/t9000/test.pl b/t/t9000/test.pl
index dfeaa9c65..b01642a0d 100755
--- a/t/t9000/test.pl
+++ b/t/t9000/test.pl
@@ -35,7 +35,8 @@ my @success_list = (q[Jane],
q['Jane 'Doe' <jdoe@example.com>],
q[Jane@:;\.,()<>Doe <jdoe@example.com>],
q[Jane <jdoe@example.com> Doe],
- q[<jdoe@example.com> Jane Doe]);
+ q[<jdoe@example.com> Jane Doe],
+ q[jdoe@example.com (open list:for thing (foo/bar))]);
my @known_failure_list = (q[Jane\ Doe <jdoe@example.com>],
q["Doe, Ja"ne <jdoe@example.com>],
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 4d261c2a9..fa783eb87 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -172,6 +172,22 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
test_cmp expected-cc commandline1
'
+test_expect_success $PREREQ 'cc trailer with get_maintainer output' '
+ write_script expected-cc-script.sh <<-EOF &&
+echo "One Person <one@example.com> (supporter:THIS (FOO/bar))"
+echo "Two Person <two@example.com> (maintainer:THIS THING)"
+echo "Third List <three@example.com> (moderated list:THIS THING (FOO/bar))"
+echo "<four@example.com> (moderated list:FOR THING)"
+echo "five@example.com (open list:FOR THING (FOO/bar))"
+echo "six@example.com (open list)"
+EOF
+ clean_fake_sendmail &&
+ git send-email -1 --to=recipient@example.com \
+ --cc-cmd=./expected-cc-script.sh \
+ --smtp-server="$(pwd)/fake.sendmail" &&
+ test_cmp expected-cc commandline1
+'
+
test_expect_success $PREREQ 'setup expect' "
cat >expected-show-all-headers <<\EOF
0001-Second.patch
--
2.15.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-20 11:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-20 11:44 [PATCH v2] git-send-email: fix --cc-cmd get_maintainer.pl regression Alex Bennée
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).