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

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 <ospite@studenti.unina.it> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Antonio Ospite committed Nov 12, 2010 at 15:55 UTC db54c8e710397fbd58892daead6181b424d6d70a
3 files changed +25 -7
Documentation/git-send-email.txt
+20 -5
@@ -82,11 +82,26 @@ See the CONFIGURATION section for 'sendemail.multiedit'.
82 set, as returned by "git var -l".
83
84 --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.
105
106 --subject=<string>::
107 Specify the initial subject of the email thread.
git-send-email.perl
+2 -1
@@ -1319,7 +1319,8 @@ foreach my $t (@files) {
1319
1320 # set up for the next message
1321 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)) {
1324 $reply_to = $message_id;
1325 if (length $references > 0) {
1326 $references .= "\n $message_id";
t/t9001-send-email.sh
+3 -1
@@ -324,9 +324,11 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
324 --smtp-server="$(pwd)/fake.sendmail" \
325 $patches $patches $patches \
326 2>errors &&
327 - # All the messages are replies to --in-reply-to
327 + # The first message is a reply to --in-reply-to
328 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
329 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 &&
332 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
333 test_cmp expect actual &&
334 sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&