summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorMarvin Häuser <mhaeuser@posteo.de>2021-08-30 15:30:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-08-30 20:25:28 (GMT)
commite0821134846b10952efc0737b9e32ca8226f0a4d (patch)
tree23152be12ece98f3ce37531d4a0cee4ca4c5abde /git-send-email.perl
parent48bf2fa8bad054d66bd79c6ba903c89c704201f7 (diff)
downloadgit-e0821134846b10952efc0737b9e32ca8226f0a4d.zip
git-e0821134846b10952efc0737b9e32ca8226f0a4d.tar.gz
git-e0821134846b10952efc0737b9e32ca8226f0a4d.tar.bz2
send-email: avoid incorrect header propagation
If multiple independent patches are sent with send-email, even if the "In-Reply-To" and "References" headers are not managed by --thread or --in-reply-to, their values may be propagated from prior patches to subsequent patches with no such headers defined. To mitigate this and potential future issues, make sure all global patch-specific variables are always either handled by command-specific code (e.g. threading), or are reset to their default values for every iteration. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl26
1 files changed, 17 insertions, 9 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 1f425c0..2991057 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1608,7 +1608,6 @@ EOF
$in_reply_to = $initial_in_reply_to;
$references = $initial_in_reply_to || '';
-$subject = $initial_subject;
$message_num = 0;
# Prepares the email, prompts the user, sends it out
@@ -1631,6 +1630,7 @@ sub process_file {
@xh = ();
my $input_format = undef;
my @header = ();
+ $subject = $initial_subject;
$message = "";
$message_num++;
# First unfold multiline header fields
@@ -1837,15 +1837,23 @@ sub process_file {
}
# set up for the next message
- if ($thread && $message_was_sent &&
- ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 ||
- $message_num == 1)) {
- $in_reply_to = $message_id;
- if (length $references > 0) {
- $references .= "\n $message_id";
- } else {
- $references = "$message_id";
+ if ($thread) {
+ if ($message_was_sent &&
+ ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 ||
+ $message_num == 1)) {
+ $in_reply_to = $message_id;
+ if (length $references > 0) {
+ $references .= "\n $message_id";
+ } else {
+ $references = "$message_id";
+ }
}
+ } elsif (!defined $initial_in_reply_to) {
+ # --thread and --in-reply-to manage the "In-Reply-To" header and by
+ # extension the "References" header. If these commands are not used, reset
+ # the header values to their defaults.
+ $in_reply_to = undef;
+ $references = '';
}
$message_id = undef;
$num_sent++;