send-email: restore --in-reply-to superseding behavior
PATCH 1/1 send-email: restore --in-reply-to superseding behavior
git send-email --in-reply-to= fails to override the email headers, if they're present in the output of format-patch, which breakes the contract of the command line switch. This can cause an email thread to break, if subsequent replies to a given message need to be sent after amending fixes to a commit and re-running git format-patch to get the incremental patch-fix posted.
--- git-send-email.perl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
git-send-email.perl +6 -2
@@ -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) { + $in_reply_to = $1; + } } elsif (/^References: (.*)/i) { - $references = $1; + if (!$initial_in_reply_to) { + $references = $1; + } } elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) { push @xh, $_;
Signature · 1 line
2.23.0
Quoted 2 lines · Rafael Aquini
git send-email --in-reply-to= fails to override the email headers, if they're present in the output of format-patch, which breakes the
Will do s/breakes/breaks/ while applying.
It makes me wonder, however, why it is a good idea to have the I-R-T in the format patch output in the first place.
git-send-email.perl sub process_file { · line 1704
Quoted 5 lines
git-send-email.perl +3
-1elsif (/^In-Reply-To: (.*)/i) { - $in_reply_to = $1; + if (!$initial_in_reply_to) { + $in_reply_to = $1; + }
I can see how this would work the way it should for the first message we send out, so it would work well for a single patch.
But what does this change do to the chaining (either making [PATCH 1/N] thru [PATCH N/N] as responses to the cover letter [PATCH 0/N], or making [PATCH n+1/N] as response to [PATCH n/N] for 1 <= n < N) of multiple messages?
When you prepare a series whose 1..N/N are all pointing at 0/N with the already prepared In-Reply-To (so you have N+1 files to send out), wouldn't you want to make 0/N a reply to a particular message you specify on the command line, while keeping the relationship among your messages intact? Doesn't having $initial_in_reply_to (i.e. command line override) help above code break the chaning?
Quoted 9 lines
git-send-email.perl +3
-1} elsif (/^References: (.*)/i) { - $references = $1; + if (!$initial_in_reply_to) { + $references = $1; + } } elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) { push @xh, $_;
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Rafael Aquini
git send-email --in-reply-to= fails to override the email headers, if they're present in the output of format-patch, which breakes the
Will do s/breakes/breaks/ while applying.
UGH! I've been fat-fingering typos the whole day, today... Sorry about that one.
Quoted 17 lines
It makes me wonder, however, why it is a good idea to have the I-R-T in the format patch output in the first place.
Review
Quoted 5 lines
(quoted diff) +3
-1elsif (/^In-Reply-To: (.*)/i) { - $in_reply_to = $1; + if (!$initial_in_reply_to) { + $in_reply_to = $1; + }I can see how this would work the way it should for the first message we send out, so it would work well for a single patch.
But what does this change do to the chaining (either making [PATCH 1/N] thru [PATCH N/N] as responses to the cover letter [PATCH 0/N], or making [PATCH n+1/N] as response to [PATCH n/N] for 1 <= n < N) of multiple messages?
Quoted 7 lines
When you prepare a series whose 1..N/N are all pointing at 0/N with the already prepared In-Reply-To (so you have N+1 files to send out), wouldn't you want to make 0/N a reply to a particular message you specify on the command line, while keeping the relationship among your messages intact? Doesn't having $initial_in_reply_to (i.e. command line override) help above code break the chaning?
This change will make all emails to appear as a reply to the msgid fed to --in-reply-to. I see your point, though, and at its light I think now this patch, is actually incomplete.
With this change we get back the override desired behavior, but it also breaks the contract, according to the 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. The second and subsequent emails will be sent as replies according to the --[no-]chain-reply-to setting.
"
I drove the change based on my usecase, which is marginal to the multi-part reply case.
I guess we just need the following, for a complete solution:
git-send-email.perl +6 -2
@@ -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, $_;
Quoted 70 lines · Rafael Aquini
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Rafael Aquini
git send-email --in-reply-to= fails to override the email headers, if they're present in the output of format-patch, which breakes the
Will do s/breakes/breaks/ while applying.
UGH! I've been fat-fingering typos the whole day, today... Sorry about that one.
Quoted 17 lines
It makes me wonder, however, why it is a good idea to have the I-R-T in the format patch output in the first place.
git-send-email.perl sub process_file { · line 1704
Quoted 5 lines
git-send-email.perl +3
-1elsif (/^In-Reply-To: (.*)/i) { - $in_reply_to = $1; + if (!$initial_in_reply_to) { + $in_reply_to = $1; + }I can see how this would work the way it should for the first message we send out, so it would work well for a single patch.
But what does this change do to the chaining (either making [PATCH 1/N] thru [PATCH N/N] as responses to the cover letter [PATCH 0/N], or making [PATCH n+1/N] as response to [PATCH n/N] for 1 <= n < N) of multiple messages?
Quoted 7 lines
When you prepare a series whose 1..N/N are all pointing at 0/N with the already prepared In-Reply-To (so you have N+1 files to send out), wouldn't you want to make 0/N a reply to a particular message you specify on the command line, while keeping the relationship among your messages intact? Doesn't having $initial_in_reply_to (i.e. command line override) help above code break the chaning?
This change will make all emails to appear as a reply to the msgid fed to --in-reply-to. I see your point, though, and at its light I think now this patch, is actually incomplete.
With this change we get back the override desired behavior, but it also breaks the contract, according to the 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. The second and subsequent emails will be sent as replies according to the --[no-]chain-reply-to setting.
"I drove the change based on my usecase, which is marginal to the multi-part reply case.
I guess we just need the following, for a complete solution:
git-send-email.perl +2
-1@@ -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;
git-send-email.perl sub process_file { · line 1712
Quoted 10 lines
git-send-email.perl +4
-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, $_;
This guy worked like a charm, and git send-email, now, follows what the man page says wrt the --in-reply-to usage.
I'll reformat the commit log, and repost the patch ASAP, if you are OK with it.
-- Rafael
a test case in t/t9001-send-email.sh will also help, as I am not sure this might be "expected behaviour" as hinted in the man page for git-send-email (under --thread):
"It is up to the user to ensure that no In-Reply-To header already exists
exists when git send-email is asked to add it (especially note that git format-patch can be configured to do the threading itself). Failure to do so may not produce the expected result in the recipient's MUA."
Carlo
Quoted 10 lines · Carlo Arenas
a test case in
t/t9001-send-email.shwill also help, as I am not sure this might be "expected behaviour" as hinted in the man page for git-send-email (under --thread):"It is up to the user to ensure that no In-Reply-To header already exists
exists when git send-email is asked to add it (especially note that git format-patch can be configured to do the threading itself). Failure to do so may not produce the expected result in the recipient's MUA."
A quick note: this change does not break that assumption, as well. The "ensure it exists" part means the header must either be in the messages, as populated by format-patch, or it is provided by the --in-reply-to switch option. send-email --thread is not orthogonal, but complementar with --in-reply-to, AFAICS.
The problem we have, right now, is that "send-email --in-reply-to" input gets dropped on the floor if you don't explicitly do "format-patch --no-thread" (or extract a single patch), and this is a behavior regression introduced after v2.17.2
I took a glance in the test-cases, an it seems this is already covered:
test_expect_success $PREREQ 'in-reply-to but no threading' '
git send-email \
--dry-run \
--from="Example <[email protected]>" \
[email protected] \
--in-reply-to="<[email protected]>" \
--no-thread \
$patches >out &&
grep "In-Reply-To: <[email protected]>" out'
Cheers,
-- Rafael
PATCH v2 1/1 send-email: restore --in-reply-to superseding behavior
In reply to Junio C Hamanogit 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.
---
v2 changelog:
* conform to the command manual page, when send-email threading is requested
git-send-email.perl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
git-send-email.perl +6 -2
@@ -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, $_;
Signature · 1 line
2.23.0
Quoted 5 lines · Rafael Aquini
This patch fixes the aformentioned issue, by bringing --in-reply-to's old overriding behavior back.
Fixes 256be1d3f0 (send-email: avoid duplicate In-Reply-To/References, 2018-04-17)
the following test case could be squashed on top to make the regression more visible IMHO (it at least pass when applied on top of v2.17.1 and also ra/send-email-in-reply-to-from-command-line-wins)
--- 8< ---
t/t9001-send-email.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
t/t9001-send-email.sh +13 -1
@@ -42,7 +42,8 @@ clean_fake_sendmail () { } test_expect_success $PREREQ 'Extract patches' ' - patches=$(git format-patch -s --cc="One <[email protected]>" [email protected] -n HEAD^1) + patches=$(git format-patch -s --cc="One <[email protected]>" [email protected] -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 <[email protected]>" \ + [email protected] \ + --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 <[email protected]>" && git send-email \
base-commit: 096547052491426a29e040a5bd94d7f8a4cab8ac --- >8 ---
Quoted 11 lines
git-send-email.perl +2
-1@@ -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;
git-send-email.perl sub process_file { · line 1712
Quoted 10 lines
git-send-email.perl +4
-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, $_;
in both cases, doing !defined $initial_in_reply_to might seem like a more consistent option.
Carlo