Skip to content

Commit db54c8e

Browse files
Antonio Ospitegitster
authored andcommitted
git-send-email.perl: make initial In-Reply-To apply only to first email
When an initial --in-reply-to is supplied, make it apply only to the first message; --[no-]chain-reply-to setting are honored by second and subsequent messages; this is also how the git-format-patch option with the same name behaves. Moreover, when $initial_reply_to is asked to the user interactively it is asked as the "Message-ID to be used as In-Reply-To for the _first_ email", this makes the user think that the second and subsequent patches are not using it but are considered as replies to the first message or chained according to the --[no-]chain-reply setting. Look at the v2 series in the illustration to see what the new behavior ensures: (before the patch) | (after the patch) [PATCH 0/2] Here is what I did... | [PATCH 0/2] Here is what I did... [PATCH 1/2] Clean up and tests | [PATCH 1/2] Clean up and tests [PATCH 2/2] Implementation | [PATCH 2/2] Implementation [PATCH v2 0/3] Here is a reroll | [PATCH v2 0/3] Here is a reroll [PATCH v2 1/3] Clean up | [PATCH v2 1/3] Clean up [PATCH v2 2/3] New tests | [PATCH v2 2/3] New tests [PATCH v2 3/3] Implementation | [PATCH v2 3/3] Implementation This is the typical behaviour we want when we send a series with cover letter in reply to some discussion, the new patch series should appear as a separate subtree in the discussion. Also update the documentation on --in-reply-to to describe the new behavior. Signed-off-by: Antonio Ospite <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54aae5e commit db54c8e

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

Documentation/git-send-email.txt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,26 @@ See the CONFIGURATION section for 'sendemail.multiedit'.
8282
set, as returned by "git var -l".
8383

8484
--in-reply-to=<identifier>::
85-
Specify the contents of the first In-Reply-To header.
86-
Subsequent emails will refer to the previous email
87-
instead of this if --chain-reply-to is set.
88-
Only necessary if --compose is also set. If --compose
89-
is not set, this will be prompted for.
85+
Make the first mail (or all the mails with `--no-thread`) appear as a
86+
reply to the given Message-Id, which avoids breaking threads to
87+
provide a new patch series.
88+
The second and subsequent emails will be sent as replies according to
89+
the `--[no]-chain-reply-to` setting.
90+
+
91+
So for example when `--thread` and `--no-chain-reply-to` are specified, the
92+
second and subsequent patches will be replies to the first one like in the
93+
illustration below where `[PATCH v2 0/3]` is in reply to `[PATCH 0/2]`:
94+
+
95+
[PATCH 0/2] Here is what I did...
96+
[PATCH 1/2] Clean up and tests
97+
[PATCH 2/2] Implementation
98+
[PATCH v2 0/3] Here is a reroll
99+
[PATCH v2 1/3] Clean up
100+
[PATCH v2 2/3] New tests
101+
[PATCH v2 3/3] Implementation
102+
+
103+
Only necessary if --compose is also set. If --compose
104+
is not set, this will be prompted for.
90105

91106
--subject=<string>::
92107
Specify the initial subject of the email thread.

git-send-email.perl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,8 @@ sub send_message {
13191319

13201320
# set up for the next message
13211321
if ($thread && $message_was_sent &&
1322-
(chain_reply_to() || !defined $reply_to || length($reply_to) == 0)) {
1322+
(chain_reply_to() || !defined $reply_to || length($reply_to) == 0 ||
1323+
$message_num == 1)) {
13231324
$reply_to = $message_id;
13241325
if (length $references > 0) {
13251326
$references .= "\n $message_id";

t/t9001-send-email.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,11 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
324324
--smtp-server="$(pwd)/fake.sendmail" \
325325
$patches $patches $patches \
326326
2>errors &&
327-
# All the messages are replies to --in-reply-to
327+
# The first message is a reply to --in-reply-to
328328
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
329329
test_cmp expect actual &&
330+
# Second and subsequent messages are replies to the first one
331+
sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
330332
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
331333
test_cmp expect actual &&
332334
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&

0 commit comments

Comments
 (0)