Skip to content

Commit 4a47a4d

Browse files
Krzysztof Mazurpeff
authored andcommitted
git-send-email: use compose-encoding for Subject
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 62e0069 commit 4a47a4d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

git-send-email.perl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,15 @@ sub get_patch_subject {
636636
my $need_8bit_cte = file_has_nonascii($compose_filename);
637637
my $in_body = 0;
638638
my $summary_empty = 1;
639+
if (!defined $compose_encoding) {
640+
$compose_encoding = "UTF-8";
641+
}
639642
while(<$c>) {
640643
next if m/^GIT:/;
641644
if ($in_body) {
642645
$summary_empty = 0 unless (/^\n$/);
643646
} elsif (/^\n$/) {
644647
$in_body = 1;
645-
if (!defined $compose_encoding) {
646-
$compose_encoding = "UTF-8";
647-
}
648648
if ($need_8bit_cte) {
649649
print $c2 "MIME-Version: 1.0\n",
650650
"Content-Type: text/plain; ",
@@ -658,7 +658,7 @@ sub get_patch_subject {
658658
my $subject = $initial_subject;
659659
$_ = "Subject: " .
660660
($subject =~ /[^[:ascii:]]/ ?
661-
quote_rfc2047($subject) :
661+
quote_rfc2047($subject, $compose_encoding) :
662662
$subject) .
663663
"\n";
664664
} elsif (/^In-Reply-To:\s*(.+)\s*$/i) {

t/t9001-send-email.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,20 @@ test_expect_success $PREREQ '--compose-encoding overrides sendemail.composeencod
909909
grep "^Content-Type: text/plain; charset=iso-8859-2" msgtxt1
910910
'
911911

912+
test_expect_success $PREREQ '--compose-encoding adds correct MIME for subject' '
913+
clean_fake_sendmail &&
914+
GIT_EDITOR="\"$(pwd)/fake-editor\"" \
915+
git send-email \
916+
--compose-encoding iso-8859-2 \
917+
--compose --subject utf8-sübjëct \
918+
--from="Example <[email protected]>" \
919+
920+
--smtp-server="$(pwd)/fake.sendmail" \
921+
$patches &&
922+
grep "^fake edit" msgtxt1 &&
923+
grep "^Subject: =?iso-8859-2?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
924+
'
925+
912926
test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
913927
echo master > master &&
914928
git add master &&

0 commit comments

Comments
 (0)