path: root/pretty.c
diff options
authorEmma Brooks <>2020-04-08 04:31:38 (GMT)
committerJunio C Hamano <>2020-04-08 05:37:18 (GMT)
commit19d097e3d73b4d3635bbe0e8735b2f059d59f29a (patch)
tree46a74286c5a82ccc9805a758ba449d07ad8a767f /pretty.c
parent9fadedd637b312089337d73c3ed8447e9f0aa775 (diff)
format-patch: teach --no-encode-email-headers
When commit subjects or authors have non-ASCII characters, git format-patch Q-encodes them so they can be safely sent over email. However, if the patch transfer method is something other than email (web review tools, sneakernet), this only serves to make the patch metadata harder to read without first applying it (unless you can decode RFC 2047 in your head). git am as well as some email software supports non-Q-encoded mail as described in RFC 6531. Add --[no-]encode-email-headers and format.encodeEmailHeaders to let the user control this behavior. Signed-off-by: Emma Brooks <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'pretty.c')
1 files changed, 4 insertions, 2 deletions
diff --git a/pretty.c b/pretty.c
index 28afc70..2a3d46b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -474,7 +474,8 @@ void pp_user_info(struct pretty_print_context *pp,
strbuf_addstr(sb, "From: ");
- if (needs_rfc2047_encoding(namebuf, namelen)) {
+ if (pp->encode_email_headers &&
+ needs_rfc2047_encoding(namebuf, namelen)) {
add_rfc2047(sb, namebuf, namelen,
encoding, RFC2047_ADDRESS);
max_length = 76; /* per rfc2047 */
@@ -1767,7 +1768,8 @@ void pp_title_line(struct pretty_print_context *pp,
if (pp->print_email_subject) {
if (pp->rev)
fmt_output_email_subject(sb, pp->rev);
- if (needs_rfc2047_encoding(title.buf, title.len))
+ if (pp->encode_email_headers &&
+ needs_rfc2047_encoding(title.buf, title.len))
add_rfc2047(sb, title.buf, title.len,
encoding, RFC2047_SUBJECT);