Skip to content

Commit b7ebe8f

Browse files
committed
Merge branch 'ra/send-email-in-reply-to-from-command-line-wins' into master
"git send-email --in-reply-to=<msg>" did not use the In-Reply-To: header with the value given from the command line, and let it be overridden by the value on In-Reply-To: header in the messages being sent out (if exists). * ra/send-email-in-reply-to-from-command-line-wins: send-email: restore --in-reply-to superseding behavior
2 parents b2b7a54 + f9f60d7 commit b7ebe8f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

git-send-email.perl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,10 +1699,14 @@ sub process_file {
16991699
$xfer_encoding = $1 if not defined $xfer_encoding;
17001700
}
17011701
elsif (/^In-Reply-To: (.*)/i) {
1702-
$in_reply_to = $1;
1702+
if (!$initial_in_reply_to || $thread) {
1703+
$in_reply_to = $1;
1704+
}
17031705
}
17041706
elsif (/^References: (.*)/i) {
1705-
$references = $1;
1707+
if (!$initial_in_reply_to || $thread) {
1708+
$references = $1;
1709+
}
17061710
}
17071711
elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
17081712
push @xh, $_;

t/t9001-send-email.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ clean_fake_sendmail () {
4242
}
4343

4444
test_expect_success $PREREQ 'Extract patches' '
45-
patches=$(git format-patch -s --cc="One <[email protected]>" [email protected] -n HEAD^1)
45+
patches=$(git format-patch -s --cc="One <[email protected]>" [email protected] -n HEAD^1) &&
46+
threaded_patches=$(git format-patch -o threaded -s --in-reply-to="format" HEAD^1)
4647
'
4748

4849
# 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' '
12191220
grep "In-Reply-To: " stdout
12201221
'
12211222

1223+
test_expect_success $PREREQ 'override in-reply-to if no threading' '
1224+
git send-email \
1225+
--dry-run \
1226+
--from="Example <[email protected]>" \
1227+
1228+
--no-thread \
1229+
--in-reply-to="override" \
1230+
$threaded_patches >stdout &&
1231+
grep "In-Reply-To: <override>" stdout
1232+
'
1233+
12221234
test_expect_success $PREREQ 'sendemail.to works' '
12231235
git config --replace-all sendemail.to "Somebody <[email protected]>" &&
12241236
git send-email \

0 commit comments

Comments
 (0)