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

[PATCH 3/3] hooks/post-receive-email: set declared encoding to utf-8

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 2, 2013, 23:24 UTC
Message-ID
<20130802232417.GE2963@elie.Belkin>
In-Reply-To
<20130802232118.GB2963@elie.Belkin>
From: Gerrit Pape <pape@smarden.org>
Date: Thu, 11 Dec 2008 20:27:21 +0000

Some email clients (e.g., claws-mail) display the message body incorrectly when the charset is not defined explicitly in a Content-Type header. "git log" generates logs in UTF-8 encoding by default, so add a Content-Type header declaring that encoding to the emails the post-receive-email example hook sends.

[jn: also setting the Content-Transfer-Encoding so MTAs know what
 kind of mangling might be needed when sending to a non 8-bit clean
 SMTP host]
Requested-by: Alexander Gerasiov <gq@debian.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
That's the end of the series.  Thanks for reading.
 contrib/hooks/post-receive-email | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index ba93a0d8..8ee410f8 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -242,6 +242,9 @@ generate_email_header()
 	cat <<-EOF
 	To: $recipients
 	Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe
+	MIME-Version: 1.0
+	Content-Type: text/plain; charset=utf-8
+	Content-Transfer-Encoding: 8bit
 	X-Git-Refname: $refname
 	X-Git-Reftype: $refname_type
 	X-Git-Oldrev: $oldrev
-- 
1.8.4.rc1
Previous: Alexey Shumkin
Message 7 of 7 in “post-receive-email: explicitly set Content-Type header”
  1. 0/3 post-receive-email: explicitly set Content-Type headerJonathan Nieder, Aug 2, 2013
  2. 1/3 hooks/post-receive-email: use plumbing instead of git log/showJonathan Nieder, Aug 2, 2013
  3. 2/3 hooks/post-receive-email: force log messages in UTF-8Jonathan Nieder, Aug 2, 2013
  4. Alexey ShumkinAug 4, 2013
  5. Jonathan NiederAug 4, 2013
  6. Alexey ShumkinAug 5, 2013
  7. 3/3 hooks/post-receive-email: set declared encoding to utf-8Jonathan Nieder, Aug 2, 2013

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.