From: Paolo Bonzini <bonzini@gnu.org>
To: git@vger.kernel.org
Cc: lersek@redhat.com, Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 1/2] git-send-email: delay creation of MIME headers
Date: Tue, 25 Nov 2014 15:00:26 +0100 [thread overview]
Message-ID: <1416924027-29862-2-git-send-email-bonzini@gnu.org> (raw)
In-Reply-To: <1416924027-29862-1-git-send-email-bonzini@gnu.org>
From: Paolo Bonzini <pbonzini@redhat.com>
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>
---
git-send-email.perl | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 9949db0..b29a304 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1324,6 +1324,8 @@ foreach my $t (@files) {
my $author_encoding;
my $has_content_type;
my $body_encoding;
+ my $xfer_encoding;
+ my $has_mime_version;
@to = ();
@cc = ();
@xh = ();
@@ -1394,9 +1396,16 @@ foreach my $t (@files) {
}
push @xh, $_;
}
+ elsif (/^MIME-Version/i) {
+ $has_mime_version = 1;
+ push @xh, $_;
+ }
elsif (/^Message-Id: (.*)/i) {
$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/) {
push @xh, $_;
}
@@ -1444,10 +1453,9 @@ foreach my $t (@files) {
if defined $cc_cmd && !$suppress_cc{'cccmd'};
if ($broken_encoding{$t} && !$has_content_type) {
+ $xfer_encoding = '8bit' if not defined $xfer_encoding;
$has_content_type = 1;
- push @xh, "MIME-Version: 1.0",
- "Content-Type: text/plain; charset=$auto_8bit_encoding",
- "Content-Transfer-Encoding: 8bit";
+ push @xh, "Content-Type: text/plain; charset=$auto_8bit_encoding";
$body_encoding = $auto_8bit_encoding;
}
@@ -1467,14 +1475,19 @@ foreach my $t (@files) {
}
}
else {
+ $xfer_encoding = '8bit' if not defined $xfer_encoding;
$has_content_type = 1;
push @xh,
- 'MIME-Version: 1.0',
- "Content-Type: text/plain; charset=$author_encoding",
- 'Content-Transfer-Encoding: 8bit';
+ "Content-Type: text/plain; charset=$author_encoding";
}
}
}
+ 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 = (
$confirm eq "always" or
--
2.1.0
next prev parent reply other threads:[~2014-11-25 14:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 14:00 [PATCH 0/2] git-send-email: add --transfer-encoding option for conversion to specified encoding Paolo Bonzini
2014-11-25 14:00 ` Paolo Bonzini [this message]
2014-11-25 14:00 ` [PATCH 2/2] git-send-email: add --transfer-encoding option Paolo Bonzini
2014-11-25 20:44 ` Eric Sunshine
2014-11-25 23:37 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416924027-29862-2-git-send-email-bonzini@gnu.org \
--to=bonzini@gnu.org \
--cc=git@vger.kernel.org \
--cc=lersek@redhat.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).