git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] send-email: only allow one address per body tag

From
Johan Hovold <johan@kernel.org>
Date
Feb 20, 2017, 11:44 UTC
Message-ID
<20170220114406.19436-1-johan@kernel.org>
In-Reply-To
<xmqqbmu0pgg6.fsf@gitster.mtv.corp.google.com>

Adding comments after a tag in the body is a common practise (e.g. in the Linux kernel) and git-send-email has been supporting this for years by removing any trailing cruft after the address.

After some recent changes, any trailing comment is now instead appended to the recipient name (with some random white space inserted) resulting in undesirable noise in the headers, for example:

CC: "# 3 . 3 . x : 1b9508f : sched : Rate-limit newidle" <stable@vger.kernel.org>

Revert to the earlier behaviour of discarding anything after the (first) address in a tag while parsing the body.

Note that multiple addresses after are still allowed after a command line switch (and in a CC header field).

Also note that --suppress-cc=self was never honoured when using multiple addresses in a tag.

Fixes: b1c8a11c8024 ("send-email: allow multiple emails using --cc, --to
and --bcc")
Fixes: e3fdbcc8e164 ("parse_mailboxes: accept extra text after <...>
address")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
v2:
 - update the cc-trailer test
 - amend commit message and mention the broken --suppress-cc=self
 git-send-email.perl   | 2 +-
 t/t9001-send-email.sh | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 068d60b3e698..eea0a517f71b 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1563,7 +1563,7 @@ foreach my $t (@files) {
 	# Now parse the message body
 	while(<$fh>) {
 		$message .=  $_;
-		if (/^(Signed-off-by|Cc): (.*)$/i) {
+		if (/^(Signed-off-by|Cc): ([^>]*>?)/i) {
 			chomp;
 			my ($what, $c) = ($1, $2);
 			chomp $c;
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 0f398dd1603d..60a80f60b268 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -148,7 +148,6 @@ cat >expected-cc <<\EOF
 !two@example.com!
 !three@example.com!
 !four@example.com!
-!five@example.com!
 EOF
 "
 
@@ -159,9 +158,9 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
 	Test Cc: trailers.
 
 	Cc: one@example.com
-	Cc: <two@example.com> # this is part of the name
-	Cc: <three@example.com>, <four@example.com> # not.five@example.com
-	Cc: "Some # Body" <five@example.com> [part.of.name.too]
+	Cc: <two@example.com> # trailing comments are ignored
+	Cc: <three@example.com>, <not.four@example.com> one address per line
+	Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
 	EOF
 	clean_fake_sendmail &&
 	git send-email -1 --to=recipient@example.com \
-- 
2.11.1
Previous: Junio C HamanoNext: Matthieu Moy
Message 18 of 22 in “body-CC-comment regression”
  1. Johan HovoldFeb 16, 2017
  2. Junio C HamanoFeb 16, 2017
  3. Johan HovoldFeb 16, 2017
  4. Matthieu MoyFeb 16, 2017
  5. Johan HovoldFeb 17, 2017
  6. Matthieu MoyFeb 17, 2017
  7. Johan HovoldFeb 17, 2017
  8. Matthieu MoyFeb 17, 2017
  9. Johan HovoldFeb 17, 2017
  10. Junio C HamanoFeb 17, 2017
  11. Johan HovoldFeb 17, 2017
  12. Junio C HamanoFeb 17, 2017
  13. Matthieu MoyFeb 17, 2017
  14. Junio C HamanoFeb 17, 2017
  15. Matthieu MoyFeb 17, 2017
  16. Junio C HamanoFeb 17, 2017
  17. Junio C HamanoFeb 17, 2017
  18. send-email: only allow one address per body tagJohan Hovold, Feb 20, 2017
  19. Matthieu MoyFeb 20, 2017
  20. Junio C HamanoFeb 23, 2017
  21. Matthieu MoyFeb 26, 2017
  22. Linus TorvaldsFeb 17, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.