git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git format-patch doesn't add Content-type for UTF-8 diffs

From
Paul Eggert <eggert@cs.ucla.edu>
Date
Jun 30, 2014, 09:03 UTC
Message-ID
<53B127DD.8000807@cs.ucla.edu>

I've been having trouble sending my Git-generated patches to the tz mailing list. Patches containing UTF-8 text are garbled, e.g., if you visit <http://mm.icann.org/pipermail/tz/2014-June/021086.html> you'll see "Ürümqi" where the patch actually had "Ürümqi".

I've tracked this down to the fact that "git format-patch" isn't outputting a Content-Type: line in the outgoing email. I thought it was supposed to do that; the man page implies that it does.

Here's how I can reproduce the bug with the git 1.9.3 that's shipped with Fedora 20. Notice that the patch is missing the line "Content-Type: text/plain; charset=UTF-8" that the git-format-patch man page implies it should be generating, and this causes the ICANN email software to misinterpret the patch's character set encoding.

$ git init
Initialized empty Git repository in /home/eggert/junk/d/.git/
$ echo x >x
$ git add x
$ git commit -m'x'
[master (root-commit) 5d0e0ce] x
  1 file changed, 1 insertion(+)
  create mode 100644 x
$ echo '§' >x
$ git commit -am'added UTF-8'
[master 57f0669] added UTF-8
  1 file changed, 1 insertion(+), 1 deletion(-)
$ git format-patch -1
0001-added-UTF-8.patch
$ cat 0001-added-UTF-8.patch
 From 57f066927a1d8e253715b7980460d81cb549b162 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 30 Jun 2014 01:49:28 -0700
Subject: [PATCH] added UTF-8
---
  x | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/x b/x
index 587be6b..3038d22 100644
--- a/x
+++ b/x
@@ -1 +1 @@
-x
+§
--
1.9.3
Next: Jeff King
Message 1 of 4 in “git format-patch doesn't add Content-type for UTF-8 diffs”
  1. Paul EggertJun 30, 2014
  2. Jeff KingJun 30, 2014
  3. Paul EggertJun 30, 2014
  4. Torsten BögershausenJul 1, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.