git-send-email: delay creation of MIME headers
After the next patch, git-send-email will sometimes modify existing Content-Transfer-Encoding headers. Delay the addition of the header to @xh until just before sending. Do the same for MIME-Version, to avoid adding it twice. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
652e759330
commit
bb29456c89
@ -1324,6 +1324,8 @@ foreach my $t (@files) {
|
|||||||
my $author_encoding;
|
my $author_encoding;
|
||||||
my $has_content_type;
|
my $has_content_type;
|
||||||
my $body_encoding;
|
my $body_encoding;
|
||||||
|
my $xfer_encoding;
|
||||||
|
my $has_mime_version;
|
||||||
@to = ();
|
@to = ();
|
||||||
@cc = ();
|
@cc = ();
|
||||||
@xh = ();
|
@xh = ();
|
||||||
@ -1394,9 +1396,16 @@ foreach my $t (@files) {
|
|||||||
}
|
}
|
||||||
push @xh, $_;
|
push @xh, $_;
|
||||||
}
|
}
|
||||||
|
elsif (/^MIME-Version/i) {
|
||||||
|
$has_mime_version = 1;
|
||||||
|
push @xh, $_;
|
||||||
|
}
|
||||||
elsif (/^Message-Id: (.*)/i) {
|
elsif (/^Message-Id: (.*)/i) {
|
||||||
$message_id = $1;
|
$message_id = $1;
|
||||||
}
|
}
|
||||||
|
elsif (/^Content-Transfer-Encoding: (.*)/i) {
|
||||||
|
$xfer_encoding = $1 if not defined $xfer_encoding;
|
||||||
|
}
|
||||||
elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
|
elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
|
||||||
push @xh, $_;
|
push @xh, $_;
|
||||||
}
|
}
|
||||||
@ -1444,10 +1453,9 @@ foreach my $t (@files) {
|
|||||||
if defined $cc_cmd && !$suppress_cc{'cccmd'};
|
if defined $cc_cmd && !$suppress_cc{'cccmd'};
|
||||||
|
|
||||||
if ($broken_encoding{$t} && !$has_content_type) {
|
if ($broken_encoding{$t} && !$has_content_type) {
|
||||||
|
$xfer_encoding = '8bit' if not defined $xfer_encoding;
|
||||||
$has_content_type = 1;
|
$has_content_type = 1;
|
||||||
push @xh, "MIME-Version: 1.0",
|
push @xh, "Content-Type: text/plain; charset=$auto_8bit_encoding";
|
||||||
"Content-Type: text/plain; charset=$auto_8bit_encoding",
|
|
||||||
"Content-Transfer-Encoding: 8bit";
|
|
||||||
$body_encoding = $auto_8bit_encoding;
|
$body_encoding = $auto_8bit_encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1467,14 +1475,19 @@ foreach my $t (@files) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$xfer_encoding = '8bit' if not defined $xfer_encoding;
|
||||||
$has_content_type = 1;
|
$has_content_type = 1;
|
||||||
push @xh,
|
push @xh,
|
||||||
'MIME-Version: 1.0',
|
"Content-Type: text/plain; charset=$author_encoding";
|
||||||
"Content-Type: text/plain; charset=$author_encoding",
|
|
||||||
'Content-Transfer-Encoding: 8bit';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (defined $xfer_encoding) {
|
||||||
|
push @xh, "Content-Transfer-Encoding: $xfer_encoding";
|
||||||
|
}
|
||||||
|
if (defined $xfer_encoding or $has_content_type) {
|
||||||
|
unshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;
|
||||||
|
}
|
||||||
|
|
||||||
$needs_confirm = (
|
$needs_confirm = (
|
||||||
$confirm eq "always" or
|
$confirm eq "always" or
|
||||||
|
Reference in New Issue
Block a user