format-patch: fix ignored encode_email_headers for cover letter
When writing the cover letter, the encode_email_headers option was ignored. That is, UTF-8 subject lines and email addresses were written out as-is, without any Q-encoding, even if --encode-email-headers was passed on the command line. This is due to encode_email_headers not being copied over from struct rev_info to struct pretty_print_context. Fix that and add a test. Signed-off-by: Simon Ser <contact@emersion.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Simon Ser committed
Nov 9, 2023 at 11:19 UTC
219d54ae8c96bcb84d0216797af7572fff7199b8
2 files changed
+11
builtin/log.c
+1
@@ -1364,6 +1364,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
1364
pp.date_mode.type = DATE_RFC2822;
1365
pp.rev = rev;
1366
pp.print_email_subject = 1;
1367
+ pp.encode_email_headers = rev->encode_email_headers;
1368
pp_user_info(&pp, NULL, &sb, committer, encoding);
1369
prepare_cover_text(&pp, description_file, branch_name, &sb,
1370
encoding, need_8bit_cte);
t/t4014-format-patch.sh
+10
@@ -1906,6 +1906,16 @@ body" &&
1906
grep "^body$" actual
1907
'
1908
1909
+test_expect_success 'cover letter with --cover-from-description subject (UTF-8 subject line)' '
1910
+ test_config branch.rebuild-1.description "Café?
1911
+
1912
+body" &&
1913
+ git checkout rebuild-1 &&
1914
+ git format-patch --stdout --cover-letter --cover-from-description subject --encode-email-headers main >actual &&
1915
+ grep "^Subject: \[PATCH 0/2\] =?UTF-8?q?Caf=C3=A9=3F?=$" actual &&
1916
+ ! grep "Café" actual
1917
+'
1918
+
1919
test_expect_success 'cover letter with format.coverFromDescription = auto (short subject line)' '
1920
test_config branch.rebuild-1.description "config subject
1921