Skip to content

Commit

Permalink
git-send-email: use compose-encoding for Subject
Browse files Browse the repository at this point in the history
The commit "git-send-email: introduce compose-encoding" introduced
the compose-encoding option to specify the introduction email encoding
(--compose option), but the email Subject encoding was still hardcoded
to UTF-8.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
Krzysztof Mazur authored and Jeff King committed Oct 25, 2012
1 parent 62e0069 commit 4a47a4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,15 @@ sub get_patch_subject {
my $need_8bit_cte = file_has_nonascii($compose_filename);
my $in_body = 0;
my $summary_empty = 1;
if (!defined $compose_encoding) {
$compose_encoding = "UTF-8";
}
while(<$c>) {
next if m/^GIT:/;
if ($in_body) {
$summary_empty = 0 unless (/^\n$/);
} elsif (/^\n$/) {
$in_body = 1;
if (!defined $compose_encoding) {
$compose_encoding = "UTF-8";
}
if ($need_8bit_cte) {
print $c2 "MIME-Version: 1.0\n",
"Content-Type: text/plain; ",
Expand All @@ -658,7 +658,7 @@ sub get_patch_subject {
my $subject = $initial_subject;
$_ = "Subject: " .
($subject =~ /[^[:ascii:]]/ ?
quote_rfc2047($subject) :
quote_rfc2047($subject, $compose_encoding) :
$subject) .
"\n";
} elsif (/^In-Reply-To:\s*(.+)\s*$/i) {
Expand Down
14 changes: 14 additions & 0 deletions t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,20 @@ test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencod
grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
'

test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
clean_fake_sendmail &&
GIT_EDITOR="\"$(pwd)/fake-editor\"" \
git send-email \
--compose-encoding iso-8859-2 \
--compose --subject utf8-sübjëct \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \
$patches &&
grep "^fake edit" msgtxt1 &&
grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
'

test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
echo master > master &&
git add master &&
Expand Down

0 comments on commit 4a47a4d

Please sign in to comment.