Skip to content

Commit

Permalink
Merge branch 'ra/send-email-in-reply-to-from-command-line-wins' into …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
gitster committed Jul 9, 2020
2 parents b2b7a54 + f9f60d7 commit b7ebe8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 6 additions & 2 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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, $_;
Expand Down
14 changes: 13 additions & 1 deletion t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit b7ebe8f

Please sign in to comment.