]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-email: restore --in-reply-to superseding behavior
authorRafael Aquini <aquini@redhat.com>
Mon, 29 Jun 2020 14:11:04 +0000 (10:11 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Jul 2020 23:12:21 +0000 (16:12 -0700)
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>
git-send-email.perl
t/t9001-send-email.sh

index dc95656f75c1c4a066665b91d31b387936998961..36c47bae1d1f1a0d3558fe43dcdbd5eb49a3d27c 100755 (executable)
@@ -1699,10 +1699,14 @@ sub process_file {
                                $xfer_encoding = $1 if not defined $xfer_encoding;
                        }
                        elsif (/^In-Reply-To: (.*)/i) {
-                               $in_reply_to = $1;
+                               if (!$initial_in_reply_to || $thread) {
+                                       $in_reply_to = $1;
+                               }
                        }
                        elsif (/^References: (.*)/i) {
-                               $references = $1;
+                               if (!$initial_in_reply_to || $thread) {
+                                       $references = $1;
+                               }
                        }
                        elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
                                push @xh, $_;
index 90f61c34009550061f5c713ff83dfe06201331f2..ec261085ec68fdb8c9e9b54a9973be880a5c7db5 100755 (executable)
@@ -42,7 +42,8 @@ clean_fake_sendmail () {
 }
 
 test_expect_success $PREREQ 'Extract patches' '
-       patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1)
+       patches=$(git format-patch -s --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1) &&
+       threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
 '
 
 # 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' '
        grep "In-Reply-To: " stdout
 '
 
+test_expect_success $PREREQ 'override in-reply-to if no threading' '
+       git send-email \
+               --dry-run \
+               --from="Example <nobody@example.com>" \
+               --to=nobody@example.com \
+               --no-thread \
+               --in-reply-to="override" \
+               $threaded_patches >stdout &&
+       grep "In-Reply-To: <override>" stdout
+'
+
 test_expect_success $PREREQ 'sendemail.to works' '
        git config --replace-all sendemail.to "Somebody <somebody@ex.com>" &&
        git send-email \