@matheusbsbs / matheus-bagliano / commits / f9f60d7066
Fork 0

send-email: restore --in-reply-to superseding behavior

git send-email --in-reply-to= fails to override In-Reply-To email headers, if they're present in the output of format-patch, even when explicitly told to do so by the option --no-thread, which breaks the contract of the command line switch option, per its man page. " --in-reply-to=<identifier> Make the first mail (or all the mails with --no-thread) appear as a reply to the given Message-Id, which avoids breaking threads to provide a new patch series. " This patch fixes the aformentioned issue, by bringing --in-reply-to's old overriding behavior back. The test was donated by Carlo Marcelo Arenas Belón. Signed-off-by: Rafael Aquini <aquini@redhat.com> Helped-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rafael Aquini committed Jun 29, 2020 at 10:11 UTC f9f60d70663a89ff06fd38c806e47fc51f29ff72
2 files changed +19 -3
git-send-email.perl
+6 -2
@@ -1699,10 +1699,14 @@ sub process_file {
1699 $xfer_encoding = $1 if not defined $xfer_encoding;
1700 }
1701 elsif (/^In-Reply-To: (.*)/i) {
1702 - $in_reply_to = $1;
1702 + if (!$initial_in_reply_to || $thread) {
1703 + $in_reply_to = $1;
1704 + }
1705 }
1706 elsif (/^References: (.*)/i) {
1705 - $references = $1;
1707 + if (!$initial_in_reply_to || $thread) {
1708 + $references = $1;
1709 + }
1710 }
1711 elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
1712 push @xh, $_;
t/t9001-send-email.sh
+13 -1
@@ -42,7 +42,8 @@ clean_fake_sendmail () {
42 }
43
44 test_expect_success $PREREQ 'Extract patches' '
45 - patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1)
45 + patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1) &&
46 + threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
47 '
48
49 # Test no confirm early to ensure remaining tests will not hang
@@ -1219,6 +1220,17 @@ test_expect_success $PREREQ 'threading but no chain-reply-to' '
1220 grep "In-Reply-To: " stdout
1221 '
1222
1223 +test_expect_success $PREREQ 'override in-reply-to if no threading' '
1224 + git send-email \
1225 + --dry-run \
1226 + --from="Example <nobody@example.com>" \
1227 + --to=nobody@example.com \
1228 + --no-thread \
1229 + --in-reply-to="override" \
1230 + $threaded_patches >stdout &&
1231 + grep "In-Reply-To: <override>" stdout
1232 +'
1233 +
1234 test_expect_success $PREREQ 'sendemail.to works' '
1235 git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
1236 git send-email \