Skip to content

Commit 0153043

Browse files
committed
Merge branch 'ao/send-email-irt'
* ao/send-email-irt: git-send-email.perl: make initial In-Reply-To apply only to first email t9001: send-email interation with --in-reply-to and --chain-reply-to
2 parents 20db370 + db54c8e commit 0153043

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,49 @@ test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
313313
! grep "^In-Reply-To: < *>" msgtxt1
314314
'
315315

316+
test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
317+
clean_fake_sendmail &&
318+
echo "<unique-message-id@example.com>" >expect &&
319+
git send-email \
320+
--from="Example <nobody@example.com>" \
321+
--to=nobody@example.com \
322+
--no-chain-reply-to \
323+
--in-reply-to="$(cat expect)" \
324+
--smtp-server="$(pwd)/fake.sendmail" \
325+
$patches $patches $patches \
326+
2>errors &&
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 &&
335+
test_cmp expect actual
336+
'
337+
338+
test_expect_success $PREREQ 'In-Reply-To with --chain-reply-to' '
339+
clean_fake_sendmail &&
340+
echo "<unique-message-id@example.com>" >expect &&
341+
git send-email \
342+
--from="Example <nobody@example.com>" \
343+
--to=nobody@example.com \
344+
--chain-reply-to \
345+
--in-reply-to="$(cat expect)" \
346+
--smtp-server="$(pwd)/fake.sendmail" \
347+
$patches $patches $patches \
348+
2>errors &&
349+
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt1 >actual &&
350+
test_cmp expect actual &&
351+
sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt1 >expect &&
352+
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt2 >actual &&
353+
test_cmp expect actual &&
354+
sed -n -e "s/^Message-Id: *\(.*\)/\1/p" msgtxt2 >expect &&
355+
sed -n -e "s/^In-Reply-To: *\(.*\)/\1/p" msgtxt3 >actual &&
356+
test_cmp expect actual
357+
'
358+
316359
test_expect_success $PREREQ 'setup fake editor' '
317360
(echo "#!$SHELL_PATH" &&
318361
echo "echo fake edit >>\"\$1\""

0 commit comments

Comments
 (0)