{"thread":{"id":"28439","subject":"[PATCH] post-receive-email: explicitly set Content-Type header","startedAt":"2011-09-20T07:52:34Z","lastAt":"2011-11-09T15:01:48Z","messageCount":12,"participants":["Alexey Shumkin","Johannes Sixt","Shumkin Alexey","Jakub Narebski","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"175839","messageId":"1316505154-3904-1-git-send-email-zapped@mail.ru","threadId":"28439","inReplyTo":null,"subject":"[PATCH] post-receive-email: explicitly set Content-Type header","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-20T07:52:34Z","receivedAt":"2011-09-20T07:52:34Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Some email clients (e.g. claws-mail) incorrectly display\nmessage body when there is no Content-Type header and charset\nexplicitly defined.\nSo, set explicitly Content-Type headrer and charset\ncan be defined with hooks.emailcharset config variable.\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n contrib/hooks/post-receive-email |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 21989fc..64d7c2f 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -60,6 +60,8 @@\n #   email body. If not specified, there is no limit.\n #   Lines beyond the limit are suppressed and counted, and a final\n #   line is added indicating the number of suppressed lines.\n+# hooks.emailcharset\n+#   The charset used in Content-Type header. UTF-8, if not specified.\n #\n # Notes\n # -----\n@@ -229,6 +231,7 @@ generate_email_header()\n \tcat <<-EOF\n \tTo: $recipients\n \tSubject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe\n+\tContent-Type: text/plain; charset=$emailcharset\n \tX-Git-Refname: $refname\n \tX-Git-Reftype: $refname_type\n \tX-Git-Oldrev: $oldrev\n@@ -723,6 +726,7 @@ envelopesender=$(git config hooks.envelopesender)\n emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')\n custom_showrev=$(git config hooks.showrev)\n maxlines=$(git config hooks.emailmaxlines)\n+emailcharset=$(git config hooks.emailcharset || echo 'UTF-8')\n \n # --- Main loop\n # Allow dual mode: run from the command line just like the update hook, or\n-- \n1.7.6.3.4.gf71f\n"},{"id":"175840","messageId":"1316506023-5098-1-git-send-email-zapped@mail.ru","threadId":"28439","inReplyTo":"1316505154-3904-1-git-send-email-zapped@mail.ru","subject":"[PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-20T08:07:03Z","receivedAt":"2011-09-20T08:07:03Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Some email clients (e.g. claws-mail) incorrectly display\nmessage body when there is no Content-Type header and charset\nexplicitly defined.\nSo, set explicitly Content-Type header and charset\ncan be defined with hooks.emailcharset config variable.\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n [resent: Fixed typo in commit message]\n\n contrib/hooks/post-receive-email |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 21989fc..64d7c2f 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -60,6 +60,8 @@\n #   email body. If not specified, there is no limit.\n #   Lines beyond the limit are suppressed and counted, and a final\n #   line is added indicating the number of suppressed lines.\n+# hooks.emailcharset\n+#   The charset used in Content-Type header. UTF-8, if not specified.\n #\n # Notes\n # -----\n@@ -229,6 +231,7 @@ generate_email_header()\n \tcat <<-EOF\n \tTo: $recipients\n \tSubject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe\n+\tContent-Type: text/plain; charset=$emailcharset\n \tX-Git-Refname: $refname\n \tX-Git-Reftype: $refname_type\n \tX-Git-Oldrev: $oldrev\n@@ -723,6 +726,7 @@ envelopesender=$(git config hooks.envelopesender)\n emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')\n custom_showrev=$(git config hooks.showrev)\n maxlines=$(git config hooks.emailmaxlines)\n+emailcharset=$(git config hooks.emailcharset || echo 'UTF-8')\n \n # --- Main loop\n # Allow dual mode: run from the command line just like the update hook, or\n-- \n1.7.6.3.4.gf71f\n"},{"id":"175848","messageId":"4E785DC6.80105@viscovery.net","threadId":"28439","inReplyTo":"1316506023-5098-1-git-send-email-zapped@mail.ru","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-09-20T09:32:54Z","receivedAt":"2011-09-20T09:32:54Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 9/20/2011 10:07, schrieb Alexey Shumkin:\n> Some email clients (e.g. claws-mail) incorrectly display\n> message body when there is no Content-Type header and charset\n> explicitly defined.\n> So, set explicitly Content-Type header and charset\n> can be defined with hooks.emailcharset config variable.\n\nPlease write full sentences with complete punctuation and capitalization.\nPerhaps you meant to say:\n\n  Some email clients (e.g. claws-mail) display the message body\n  incorrectly when the charset is not defined explicitly in a\n  Content-Type header. Insert a Content-Type header in the message.\n\n  The charset can be defined with the config variable\n  hooks.emailcharset.\n\n> +# hooks.emailcharset\n> +#   The charset used in Content-Type header. UTF-8, if not specified.\n\nHow can you be sure that the output produced by git log etc. that are used\nin the script are in the encoding specified by this variable? IOW,\nwouldn't log.outputencoding be the better choice to use in the\nContent-Type header?\n\n-- Hannes\n"},{"id":"175853","messageId":"20110920104256.GA11656@zapped.homeip.net","threadId":"28439","inReplyTo":"4E785DC6.80105@viscovery.net","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Shumkin Alexey","fromEmail":"zapped@mail.ru","sentAt":"2011-09-20T10:42:56Z","receivedAt":"2011-09-20T10:42:56Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"[ resent to mailing list ]\nOn Tue, Sep 20, 2011 at 11:32:54AM +0200, Johannes Sixt wrote:\n> Am 9/20/2011 10:07, schrieb Alexey Shumkin:\n> > Some email clients (e.g. claws-mail) incorrectly display\n> > message body when there is no Content-Type header and charset\n> > explicitly defined.\n> > So, set explicitly Content-Type header and charset\n> > can be defined with hooks.emailcharset config variable.\n> \n> Please write full sentences with complete punctuation and capitalization.\n> Perhaps you meant to say:\n> \n>   Some email clients (e.g. claws-mail) display the message body\n>   incorrectly when the charset is not defined explicitly in a\n>   Content-Type header. Insert a Content-Type header in the message.\n> \n>   The charset can be defined with the config variable\n>   hooks.emailcharset.\nThanks for the correction. English is not my native language\n(although it is not for you, too, I guess :) ).\nI read it and take on ear fine but I have no enough practice to write on it.\n\n> > +# hooks.emailcharset\n> > +#   The charset used in Content-Type header. UTF-8, if not\n> > specified.\n> \n> How can you be sure that the output produced by git log etc. that are\n> used in the script are in the encoding specified by this variable?\n> IOW, wouldn't log.outputencoding be the better choice to use in the\n> Content-Type header?\nYes, you're right, we cannot be sure in UTF-8 encoding of output\nand using i18n.logoutputencoding would be a better choice\ninstead of new config variable.\n\nBut at the present\n1. post-send-mail uses description file of a repo\n2. gitweb also uses this file and AFAIK it assumes one to be in UTF-8\n  (I do not know whether it can be changed there but I tested gitweb once long\n    time ago)\n3. So if i18n.logoutputencoding is not UTF-8 we get a message composed\n\twith mixed encodings. This fact oblidge us to encode headers\n\t(as quoted printable at least) and synchronize body message that contain\n\trepo description (in UTF-8) and diffstat (in i18n.logoutputencoding).\n\tThis is a more complicated task for a shell script\n\tthan just specifying Content-Type header (may be git-send-email suits here?)\n\nSo that was a quick solution for me :)\n"},{"id":"175856","messageId":"4E7874B9.2060909@viscovery.net","threadId":"28439","inReplyTo":"20110920104256.GA11656@zapped.homeip.net","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-09-20T11:10:49Z","receivedAt":"2011-09-20T11:10:49Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 9/20/2011 12:42, schrieb Shumkin Alexey:\n> On Tue, Sep 20, 2011 at 11:32:54AM +0200, Johannes Sixt wrote:\n>> Am 9/20/2011 10:07, schrieb Alexey Shumkin:\n>>> +# hooks.emailcharset\n>>> +#   The charset used in Content-Type header. UTF-8, if not\n>>> specified.\n>>\n>> How can you be sure that the output produced by git log etc. that are\n>> used in the script are in the encoding specified by this variable?\n>> IOW, wouldn't log.outputencoding be the better choice to use in the\n>> Content-Type header?\n> Yes, you're right, we cannot be sure in UTF-8 encoding of output\n> and using i18n.logoutputencoding would be a better choice\n> instead of new config variable.\n> \n> But at the present\n> 1. post-send-mail uses description file of a repo\n> 2. gitweb also uses this file and AFAIK it assumes one to be in UTF-8\n>   (I do not know whether it can be changed there but I tested gitweb once long\n>     time ago)\n> 3. So if i18n.logoutputencoding is not UTF-8 we get a message composed\n> \twith mixed encodings. This fact oblidge us to encode headers\n> \t(as quoted printable at least) and synchronize body message that contain\n> \trepo description (in UTF-8) and diffstat (in i18n.logoutputencoding).\n> \tThis is a more complicated task for a shell script\n> \tthan just specifying Content-Type header (may be git-send-email suits here?)\n\nIn this case, it may make sense to have a separate setting, but you should\ncall git like this:\n\n   git -c \"i18n.logoutputencoding=$emailcharset\" show ...\n   git -c \"i18n.logoutputencoding=$emailcharset\" rev-list --pretty ...\n\n-- Hannes\n"},{"id":"175861","messageId":"m34o07s8sx.fsf@localhost.localdomain","threadId":"28439","inReplyTo":"20110920104256.GA11656@zapped.homeip.net","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-09-20T12:23:03Z","receivedAt":"2011-09-20T12:23:03Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Shumkin Alexey <zapped@mail.ru> writes:\n> [ resent to mailing list ]\n> On Tue, Sep 20, 2011 at 11:32:54AM +0200, Johannes Sixt wrote:\n> > Am 9/20/2011 10:07, schrieb Alexey Shumkin:\n[...]\n> > > +# hooks.emailcharset\n> > > +#   The charset used in Content-Type header. UTF-8, if not\n> > > specified.\n> > \n> > How can you be sure that the output produced by git log etc. that are\n> > used in the script are in the encoding specified by this variable?\n> > IOW, wouldn't log.outputencoding be the better choice to use in the\n> > Content-Type header?\n>\n> Yes, you're right, we cannot be sure in UTF-8 encoding of output\n> and using i18n.logoutputencoding would be a better choice\n> instead of new config variable.\n> \n> But at the present\n> 1. post-send-mail uses description file of a repo\n> 2. gitweb also uses this file and AFAIK it assumes one to be in UTF-8\n>   (I do not know whether it can be changed there but I tested gitweb once long\n>     time ago)\n\nI have thought that gitweb uses '--encoding=utf8' explicitly, but as I\nhave checked it uses this only for git-format-patch invocation in\n'patch' / 'patches' views.  Should be fixed.\n\n-- \nJakub Narębski\n"},{"id":"177146","messageId":"20111007090601.GA22541@elie.hsd1.il.comcast.net","threadId":"28439","inReplyTo":"4E7874B9.2060909@viscovery.net","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-10-07T09:06:02Z","receivedAt":"2011-10-07T09:06:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Johannes Sixt wrote:\n> Am 9/20/2011 12:42, schrieb Shumkin Alexey:\n\n>> 1. post-send-mail uses description file of a repo\n>> 2. gitweb also uses this file and AFAIK it assumes one to be in UTF-8\n>>   (I do not know whether it can be changed there but I tested gitweb once long\n>>     time ago)\n>> 3. So if i18n.logoutputencoding is not UTF-8 we get a message composed\n>> \twith mixed encodings. This fact oblidge us to encode headers\n>> \t(as quoted printable at least) and synchronize body message that contain\n>> \trepo description (in UTF-8) and diffstat (in i18n.logoutputencoding).\n[...]\n> In this case, it may make sense to have a separate setting, but you should\n> call git like this:\n>\n>    git -c \"i18n.logoutputencoding=$emailcharset\" show ...\n>    git -c \"i18n.logoutputencoding=$emailcharset\" rev-list --pretty ...\n\nSomething like this, I suppose?\n\nThis teaches post-receive-email to use plumbing where possible and to\nexplicitly declare what encoding it expects output to use.  Completely\nuntested --- basic sanity checking, testing, and tweaks to allow\noverriding the choice of encoding left as an exercise to the reader.\n\nBased on patches by Gerrit Pape and Jeff King and advice from Johannes\nSixt.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nMore background:\nhttp://thread.gmane.org/gmane.comp.version-control.git/124350/focus=124355\n\n contrib/hooks/post-receive-email |   15 +++++++++------\n 1 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex ba077c13..bc603b02 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -234,6 +234,9 @@ generate_email_header()\n \tcat <<-EOF\n \tTo: $recipients\n \tSubject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe\n+\tMIME-Version: 1.0\n+\tContent-Type: text/plain; charset=utf-8\n+\tContent-Transfer-Encoding: 8bit\n \tX-Git-Refname: $refname\n \tX-Git-Reftype: $refname_type\n \tX-Git-Oldrev: $oldrev\n@@ -462,7 +465,7 @@ generate_delete_branch_email()\n \techo \"       was  $oldrev\"\n \techo \"\"\n \techo $LOGEND\n-\tgit show -s --pretty=oneline $oldrev\n+\tgit diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev\n \techo $LOGEND\n }\n \n@@ -538,11 +541,11 @@ generate_atag_email()\n \t\t# performed on them\n \t\tif [ -n \"$prevtag\" ]; then\n \t\t\t# Show changes since the previous release\n-\t\t\tgit rev-list --pretty=short \"$prevtag..$newrev\" | git shortlog\n+\t\t\tgit shortlog --encoding=UTF-8 \"$prevtag..$newrev\"\n \t\telse\n \t\t\t# No previous tag, show all the changes since time\n \t\t\t# began\n-\t\t\tgit rev-list --pretty=short $newrev | git shortlog\n+\t\t\tgit shortlog --encoding=UTF-8 \"$newrev\"\n \t\tfi\n \t\t;;\n \t*)\n@@ -562,7 +565,7 @@ generate_delete_atag_email()\n \techo \"       was  $oldrev\"\n \techo \"\"\n \techo $LOGEND\n-\tgit show -s --pretty=oneline $oldrev\n+\tgit diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev\n \techo $LOGEND\n }\n \n@@ -608,7 +611,7 @@ generate_general_email()\n \techo \"\"\n \tif [ \"$newrev_type\" = \"commit\" ]; then\n \t\techo $LOGBEGIN\n-\t\tgit show --no-color --root -s --pretty=medium $newrev\n+\t\tgit diff-tree --encoding=UTF-8 --root -s --pretty=oneline $newrev\n \t\techo $LOGEND\n \telse\n \t\t# What can we do here?  The tag marks an object that is not\n@@ -627,7 +630,7 @@ generate_delete_general_email()\n \techo \"       was  $oldrev\"\n \techo \"\"\n \techo $LOGEND\n-\tgit show -s --pretty=oneline $oldrev\n+\tgit diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev\n \techo $LOGEND\n }\n \n-- \n1.7.7.rc1\n"},{"id":"177152","messageId":"20111007165209.595834f2@ashu.dyn.rarus.ru","threadId":"28439","inReplyTo":"20111007090601.GA22541@elie.hsd1.il.comcast.net","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Alexey Shumkin","fromEmail":"alex.crezoff@gmail.com","sentAt":"2011-10-07T12:52:09Z","receivedAt":"2011-10-07T12:52:09Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"> Johannes Sixt wrote:\n> > Am 9/20/2011 12:42, schrieb Shumkin Alexey:\n> \n> >> 1. post-send-mail uses description file of a repo\n> >> 2. gitweb also uses this file and AFAIK it assumes one to be in\n> >> UTF-8 (I do not know whether it can be changed there but I tested\n> >> gitweb once long time ago)\n> >> 3. So if i18n.logoutputencoding is not UTF-8 we get a message\n> >> composed with mixed encodings. This fact oblidge us to encode\n> >> headers (as quoted printable at least) and synchronize body\n> >> message that contain repo description (in UTF-8) and diffstat (in\n> >> i18n.logoutputencoding).\n> [...]\n> > In this case, it may make sense to have a separate setting, but you\n> > should call git like this:\n> >\n> >    git -c \"i18n.logoutputencoding=$emailcharset\" show ...\n> >    git -c \"i18n.logoutputencoding=$emailcharset\" rev-list\n> > --pretty ...\n> \n> Something like this, I suppose?\n> \n> This teaches post-receive-email to use plumbing where possible and to\n> explicitly declare what encoding it expects output to use.  Completely\n> untested --- basic sanity checking, testing, and tweaks to allow\n> overriding the choice of encoding left as an exercise to the reader.\n> \n> Based on patches by Gerrit Pape and Jeff King and advice from Johannes\n> Sixt.\n> \n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> More background:\n> http://thread.gmane.org/gmane.comp.version-control.git/124350/focus=124355\n> \n>  contrib/hooks/post-receive-email |   15 +++++++++------\n>  1 files changed, 9 insertions(+), 6 deletions(-)\n> \n> diff --git a/contrib/hooks/post-receive-email\n> b/contrib/hooks/post-receive-email index ba077c13..bc603b02 100755\n> --- a/contrib/hooks/post-receive-email\n> +++ b/contrib/hooks/post-receive-email\n> @@ -234,6 +234,9 @@ generate_email_header()\n>  \tcat <<-EOF\n>  \tTo: $recipients\n>  \tSubject: ${emailprefix}$projectdesc $refname_type\n> $short_refname ${change_type}d. $describe\n> +\tMIME-Version: 1.0\n> +\tContent-Type: text/plain; charset=utf-8\n> +\tContent-Transfer-Encoding: 8bit\n>  \tX-Git-Refname: $refname\n>  \tX-Git-Reftype: $refname_type\n>  \tX-Git-Oldrev: $oldrev\n> @@ -462,7 +465,7 @@ generate_delete_branch_email()\n>  \techo \"       was  $oldrev\"\n>  \techo \"\"\n>  \techo $LOGEND\n> -\tgit show -s --pretty=oneline $oldrev\n> +\tgit diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev\n>  \techo $LOGEND\n>  }\n>  \n> @@ -538,11 +541,11 @@ generate_atag_email()\n>  \t\t# performed on them\n>  \t\tif [ -n \"$prevtag\" ]; then\n>  \t\t\t# Show changes since the previous release\n> -\t\t\tgit rev-list --pretty=short\n> \"$prevtag..$newrev\" | git shortlog\n> +\t\t\tgit shortlog --encoding=UTF-8\n> \"$prevtag..$newrev\" else\n>  \t\t\t# No previous tag, show all the changes\n> since time # began\n> -\t\t\tgit rev-list --pretty=short $newrev | git\n> shortlog\n> +\t\t\tgit shortlog --encoding=UTF-8 \"$newrev\"\n>  \t\tfi\n>  \t\t;;\n>  \t*)\n> @@ -562,7 +565,7 @@ generate_delete_atag_email()\n>  \techo \"       was  $oldrev\"\n>  \techo \"\"\n>  \techo $LOGEND\n> -\tgit show -s --pretty=oneline $oldrev\n> +\tgit diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev\n>  \techo $LOGEND\n>  }\n>  \n> @@ -608,7 +611,7 @@ generate_general_email()\n>  \techo \"\"\n>  \tif [ \"$newrev_type\" = \"commit\" ]; then\n>  \t\techo $LOGBEGIN\n> -\t\tgit show --no-color --root -s --pretty=medium $newrev\n> +\t\tgit diff-tree --encoding=UTF-8 --root -s\n> --pretty=oneline $newrev echo $LOGEND\n>  \telse\n>  \t\t# What can we do here?  The tag marks an object that\n> is not @@ -627,7 +630,7 @@ generate_delete_general_email()\n>  \techo \"       was  $oldrev\"\n>  \techo \"\"\n>  \techo $LOGEND\n> -\tgit show -s --pretty=oneline $oldrev\n> +\tgit diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev\n>  \techo $LOGEND\n>  }\n>  \n\nAs I understand, this patches make email message with explicitly set\nContent-Type header (it's ok) and UTF-8 encoding (that is a subject\nto discuss).\nMy proposition was in to send email message in explicitly defined\ncustom encoding. Why? In development process under Windows non-UTF-8\nencoding is used (cp1251 in my case). So, filenames have this encoding,\nand as we know Git stores their names as is - in cp1251 - without a\nconversion. And filenames are also used in diff-stat (with\ncore.quotepath= false, BTW, I did not take into account this config)\nwithout any conversion. So if we'll make all text in UTF-8 but\nfilenames are still non-UTF-8, email would look corrupted.\n"},{"id":"177181","messageId":"20111007201932.GC29712@elie.hsd1.il.comcast.net","threadId":"28439","inReplyTo":"20111007165209.595834f2@ashu.dyn.rarus.ru","subject":"Re: [PATCH v2] post-receive-email: explicitly set Content-Type header","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-10-07T20:19:32Z","receivedAt":"2011-10-07T20:19:32Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Alexey Shumkin wrote:\n\n> In development process under Windows non-UTF-8\n> encoding is used (cp1251 in my case). So, filenames have this encoding,\n> and as we know Git stores their names as is - in cp1251 - without a\n> conversion. And filenames are also used in diff-stat (with\n> core.quotepath= false\n\nYes, when a person sets [core] quotepath to false, I think it's fair to\nassume for now that the filenames are in the same encoding as\neverything else (whether that's UTF-8 or something else).  Maybe it\nwould be possible in a separate patch to add a configurable list of\nencodings to try out when formatting paths for display.\n\nJonathan\n"},{"id":"179201","messageId":"1320836458-24088-1-git-send-email-Alex.Crezoff@gmail.com","threadId":"28439","inReplyTo":"20111007201932.GC29712@elie.hsd1.il.comcast.net","subject":"[PATCH v3] post-receive-email: explicitly set Content-Type header","fromName":"Alexey Shumkin","fromEmail":"alex.crezoff@gmail.com","sentAt":"2011-11-09T11:00:58Z","receivedAt":"2011-11-09T11:00:58Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"Some email clients (e.g. claws-mail) incorrectly display\nmessage body when there is no Content-Type header and charset\nexplicitly defined.\nSo, set explicitly Content-Type header. Its charset\ncan be defined with hooks.emailcharset config variable.\n\nNB: This above-mentioned charset may differ from i18n.logOutputEncoding,\nbecause e.g. gitweb expects (for now) i18n.logOutputEncoding set to UTF-8\nto display logs correctly.\n\nAlso, introduce hooks.gitopts config variable\nwith the default '-c core.quotepath=false'.\nThis takes into account that we want to see pretty email-message\nwith well-looking messages and list of changed filenames.\nAnd usually non-ASCII filenames are in the same\nencoding that commit messages are.\n\nSigned-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>\n---\n contrib/hooks/post-receive-email |   43 ++++++++++++++++++++++++++-----------\n 1 files changed, 30 insertions(+), 13 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex ba077c1..913be89 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -65,6 +65,14 @@\n #   Default is \"--stat --summary --find-copies-harder\". Add -p to those\n #   options to include a unified diff of changes in addition to the usual\n #   summary output.\n+# hooks.gitopts\n+#   git options for the git diff-tree invocation that shows changes.\n+#   Default is '-c core.quotepath=false' to be able to see non-ASCII filenames\n+#   used in a project.\n+# hooks.emailcharset\n+#   The charset used in Content-Type header. UTF-8, if not specified.\n+#   It can differ from i18n.logOutputEncoding (not to mess-up with gitweb\n+#   which expects i18n.logOutputEncoding to be set to UTF-8)\n #\n # Notes\n # -----\n@@ -234,6 +242,9 @@ generate_email_header()\n \tcat <<-EOF\n \tTo: $recipients\n \tSubject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe\n+\tMIME-Version: 1.0\n+\tContent-Type: text/plain; charset=$emailcharset\n+\tContent-Transfer-Encoding: 8bit\n \tX-Git-Refname: $refname\n \tX-Git-Reftype: $refname_type\n \tX-Git-Oldrev: $oldrev\n@@ -241,7 +252,7 @@ generate_email_header()\n \n \tThis is an automated email from the git hooks/post-receive script. It was\n \tgenerated because a ref change was pushed to the repository containing\n-\tthe project \"$projectdesc\".\n+\tthe project \"$projectdesc_e\".\n \n \tThe $refname_type, $short_refname has been ${change_type}d\n \tEOF\n@@ -255,7 +266,7 @@ generate_email_footer()\n \n \thooks/post-receive\n \t--${SPACE}\n-\t$projectdesc\n+\t$projectdesc_e\n \tEOF\n }\n \n@@ -451,7 +462,7 @@ generate_update_branch_email()\n \t# non-fast-forward updates.\n \techo \"\"\n \techo \"Summary of changes:\"\n-\tgit diff-tree $diffopts $oldrev..$newrev\n+\tgit $gitopts diff-tree $diffopts $oldrev..$newrev\n }\n \n #\n@@ -656,14 +667,15 @@ show_new_revisions()\n \t\trevspec=$oldrev..$newrev\n \tfi\n \n+\trevlistopts=\"-c i18n.logOutputEncoding=$emailcharset\"\n \tother_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |\n \t    grep -F -v $refname)\n \tgit rev-parse --not $other_branches |\n \tif [ -z \"$custom_showrev\" ]\n \tthen\n-\t\tgit rev-list --pretty --stdin $revspec\n+\t\tgit $revlistopts rev-list --pretty --stdin $revspec\n \telse\n-\t\tgit rev-list --stdin $revspec |\n+\t\tgit $revlistopts $rev-list --stdin $revspec |\n \t\twhile read onerev\n \t\tdo\n \t\t\teval $(printf \"$custom_showrev\" $onerev)\n@@ -714,14 +726,6 @@ if [ -z \"$GIT_DIR\" ]; then\n \texit 1\n fi\n \n-projectdesc=$(sed -ne '1p' \"$GIT_DIR/description\" 2>/dev/null)\n-# Check if the description is unchanged from it's default, and shorten it to\n-# a more manageable length if it is\n-if expr \"$projectdesc\" : \"Unnamed repository.*$\" >/dev/null\n-then\n-\tprojectdesc=\"UNNAMED PROJECT\"\n-fi\n-\n recipients=$(git config hooks.mailinglist)\n announcerecipients=$(git config hooks.announcelist)\n envelopesender=$(git config hooks.envelopesender)\n@@ -730,6 +734,19 @@ custom_showrev=$(git config hooks.showrev)\n maxlines=$(git config hooks.emailmaxlines)\n diffopts=$(git config hooks.diffopts)\n : ${diffopts:=\"--stat --summary --find-copies-harder\"}\n+gitopts=$(git config hooks.gitopts || echo '-c core.quotepath=false')\n+emailcharset=$(git config hooks.emailcharset || echo 'UTF-8')\n+\n+projectdesc=$(sed -ne '1p' \"$GIT_DIR/description\" 2>/dev/null)\n+# Check if the description is unchanged from it's default, and shorten it to\n+# a more manageable length if it is\n+if expr \"$projectdesc\" : \"Unnamed repository.*$\" >/dev/null\n+then\n+\tprojectdesc=\"UNNAMED PROJECT\"\n+fi\n+# Leave description in UTF-8 to be used in the Subject header\n+# But convert it to an hooks.emailcharset encoding to be used in a message body\n+projectdesc_e=$(echo $projectdesc | iconv -f UTF-8 -t $emailcharset 2>/dev/null)\n \n # --- Main loop\n # Allow dual mode: run from the command line just like the update hook, or\n-- \n1.7.7.3.5.g55178\n"},{"id":"179209","messageId":"7vy5vpv11n.fsf@alter.siamese.dyndns.org","threadId":"28439","inReplyTo":"1320836458-24088-1-git-send-email-Alex.Crezoff@gmail.com","subject":"Re: [PATCH v3] post-receive-email: explicitly set Content-Type header","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-09T14:11:00Z","receivedAt":"2011-11-09T14:11:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexey Shumkin <alex.crezoff@gmail.com> writes:\n\n> Some email clients (e.g. claws-mail) incorrectly display\n> message body when there is no Content-Type header and charset\n> explicitly defined.\n> So, set explicitly Content-Type header. Its charset\n> can be defined with hooks.emailcharset config variable.\n>\n> NB: This above-mentioned charset may differ from i18n.logOutputEncoding,\n> because e.g. gitweb expects (for now) i18n.logOutputEncoding set to UTF-8\n> to display logs correctly.\n>\n> Also, introduce hooks.gitopts config variable\n> with the default '-c core.quotepath=false'.\n> This takes into account that we want to see pretty email-message\n> with well-looking messages and list of changed filenames.\n> And usually non-ASCII filenames are in the same\n> encoding that commit messages are.\n\n(style) Why such an extremely ragged looking line-wrap of paragraphs?\n\n> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>\n> ---\n\nIn this space, please describe what happened during v1 and v2, and how is\nthis round different to help reviewers. Pointers to list archive, e.g.\nhttp://thread.gmane.org/gmane.comp.version-control.git/181737, would be\nhelpful.\n\nPeople involved in v1/v2 discussion are missing from the Cc: line. Please\ndo not give a false impression that you are hiding from them.\n\n> diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\n> index ba077c1..913be89 100755\n> --- a/contrib/hooks/post-receive-email\n> +++ b/contrib/hooks/post-receive-email\n> @@ -65,6 +65,14 @@\n>  #   Default is \"--stat --summary --find-copies-harder\". Add -p to those\n>  #   options to include a unified diff of changes in addition to the usual\n>  #   summary output.\n> +# hooks.gitopts\n> +#   git options for the git diff-tree invocation that shows changes.\n> +#   Default is '-c core.quotepath=false' to be able to see non-ASCII filenames\n> +#   used in a project.\n\nWe do not particularly appreciate a patch that does two unrelated things\n(\"they are both related to post-receive-email\" is not an argument).\nWouldn't this be useful even if the change to add hooks.emailcharset\nturned out to be unwanted, or vice versa?\n\n> +# hooks.emailcharset\n> +#   The charset used in Content-Type header. UTF-8, if not specified.\n> +#   It can differ from i18n.logOutputEncoding (not to mess-up with gitweb\n> +#   which expects i18n.logOutputEncoding to be set to UTF-8)\n\nWhy \"UTF-8\" instead of \"i18n.logoutputencoding\" if not specified?\n\n> @@ -234,6 +242,9 @@ generate_email_header()\n>  \tcat <<-EOF\n>  \tTo: $recipients\n>  \tSubject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe\n> +\tMIME-Version: 1.0\n> +\tContent-Type: text/plain; charset=$emailcharset\n> +\tContent-Transfer-Encoding: 8bit\n>  \tX-Git-Refname: $refname\n>  \tX-Git-Reftype: $refname_type\n>  \tX-Git-Oldrev: $oldrev\n> ...\n> @@ -730,6 +734,19 @@ custom_showrev=$(git config hooks.showrev)\n>  maxlines=$(git config hooks.emailmaxlines)\n>  diffopts=$(git config hooks.diffopts)\n>  : ${diffopts:=\"--stat --summary --find-copies-harder\"}\n> +gitopts=$(git config hooks.gitopts || echo '-c core.quotepath=false')\n> +emailcharset=$(git config hooks.emailcharset || echo 'UTF-8')\n> +\n> +projectdesc=$(sed -ne '1p' \"$GIT_DIR/description\" 2>/dev/null)\n> +# Check if the description is unchanged from it's default, and shorten it to\n> +# a more manageable length if it is\n> +if expr \"$projectdesc\" : \"Unnamed repository.*$\" >/dev/null\n> +then\n> +\tprojectdesc=\"UNNAMED PROJECT\"\n> +fi\n> +# Leave description in UTF-8 to be used in the Subject header\n> +# But convert it to an hooks.emailcharset encoding to be used in a message body\n> +projectdesc_e=$(echo $projectdesc | iconv -f UTF-8 -t $emailcharset 2>/dev/null)\n\nHmm, this generates a piece of e-mail whose subject line is in UTF-8\n(without B/Q quoting) and message body is in totally different encoding.\nIs it what mailers really want to see?\n\nIt almost seems backwards; converting the payload to UTF-8 and always\nsending UTF-8 would be a simpler approach, methinks.\n"},{"id":"179210","messageId":"20111109190148.62a81b94@ashu.dyn.rarus.ru","threadId":"28439","inReplyTo":"7vy5vpv11n.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] post-receive-email: explicitly set Content-Type header","fromName":"Alexey Shumkin","fromEmail":"alex.crezoff@gmail.com","sentAt":"2011-11-09T15:01:48Z","receivedAt":"2011-11-09T15:01:48Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"> Alexey Shumkin <alex.crezoff@gmail.com> writes:\n> \n> > Some email clients (e.g. claws-mail) incorrectly display\n> > message body when there is no Content-Type header and charset\n> > explicitly defined.\n> > So, set explicitly Content-Type header. Its charset\n> > can be defined with hooks.emailcharset config variable.\n> >\n> > NB: This above-mentioned charset may differ from\n> > i18n.logOutputEncoding, because e.g. gitweb expects (for now)\n> > i18n.logOutputEncoding set to UTF-8 to display logs correctly.\n> >\n> > Also, introduce hooks.gitopts config variable\n> > with the default '-c core.quotepath=false'.\n> > This takes into account that we want to see pretty email-message\n> > with well-looking messages and list of changed filenames.\n> > And usually non-ASCII filenames are in the same\n> > encoding that commit messages are.\n> \n> (style) Why such an extremely ragged looking line-wrap of paragraphs?\nI'm not good enough in English spelling ;(\n> \n> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>\n> > ---\n> \n> In this space, please describe what happened during v1 and v2, and\n> how is this round different to help reviewers. Pointers to list\n> archive, e.g.\n> http://thread.gmane.org/gmane.comp.version-control.git/181737, would\n> be helpful.\n> \n> People involved in v1/v2 discussion are missing from the Cc: line.\n> Please do not give a false impression that you are hiding from them.\nOh, I've missed that moment, sorry all\n> \n> > diff --git a/contrib/hooks/post-receive-email\n> > b/contrib/hooks/post-receive-email index ba077c1..913be89 100755\n> > --- a/contrib/hooks/post-receive-email\n> > +++ b/contrib/hooks/post-receive-email\n> > @@ -65,6 +65,14 @@\n> >  #   Default is \"--stat --summary --find-copies-harder\". Add -p to\n> > those #   options to include a unified diff of changes in addition\n> > to the usual #   summary output.\n> > +# hooks.gitopts\n> > +#   git options for the git diff-tree invocation that shows\n> > changes. +#   Default is '-c core.quotepath=false' to be able to\n> > see non-ASCII filenames +#   used in a project.\n> \n> We do not particularly appreciate a patch that does two unrelated\n> things (\"they are both related to post-receive-email\" is not an\n> argument). Wouldn't this be useful even if the change to add\n> hooks.emailcharset turned out to be unwanted, or vice versa?\nThe main reason was that using core.quotepath=false leads to showing\nfile names \"correctly\" according to commit messages encoding to make\nemail-message look pretty.\n> \n> > +# hooks.emailcharset\n> > +#   The charset used in Content-Type header. UTF-8, if not\n> > specified. +#   It can differ from i18n.logOutputEncoding (not to\n> > mess-up with gitweb +#   which expects i18n.logOutputEncoding to be\n> > set to UTF-8)\n> \n> Why \"UTF-8\" instead of \"i18n.logoutputencoding\" if not specified?\nWell, you're right.\nFor the explanation:\nAFAIU, such hooks are used on central servers to notify involved people\nabout changes. And AFAIU the same server repos are used with gitweb\n(which AFAIK requires i18n.logOutputEncoding=UTF-8)\n\nBut in common case \"i18n.logoutputencoding\" is more suitable.\n\n> \n> > @@ -234,6 +242,9 @@ generate_email_header()\n> >  \tcat <<-EOF\n> >  \tTo: $recipients\n> >  \tSubject: ${emailprefix}$projectdesc $refname_type\n> > $short_refname ${change_type}d. $describe\n> > +\tMIME-Version: 1.0\n> > +\tContent-Type: text/plain; charset=$emailcharset\n> > +\tContent-Transfer-Encoding: 8bit\n> >  \tX-Git-Refname: $refname\n> >  \tX-Git-Reftype: $refname_type\n> >  \tX-Git-Oldrev: $oldrev\n> > ...\n> > @@ -730,6 +734,19 @@ custom_showrev=$(git config hooks.showrev)\n> >  maxlines=$(git config hooks.emailmaxlines)\n> >  diffopts=$(git config hooks.diffopts)\n> >  : ${diffopts:=\"--stat --summary --find-copies-harder\"}\n> > +gitopts=$(git config hooks.gitopts || echo '-c\n> > core.quotepath=false') +emailcharset=$(git config\n> > hooks.emailcharset || echo 'UTF-8') +\n> > +projectdesc=$(sed -ne '1p' \"$GIT_DIR/description\" 2>/dev/null)\n> > +# Check if the description is unchanged from it's default, and\n> > shorten it to +# a more manageable length if it is\n> > +if expr \"$projectdesc\" : \"Unnamed repository.*$\" >/dev/null\n> > +then\n> > +\tprojectdesc=\"UNNAMED PROJECT\"\n> > +fi\n> > +# Leave description in UTF-8 to be used in the Subject header\n> > +# But convert it to an hooks.emailcharset encoding to be used in a\n> > message body +projectdesc_e=$(echo $projectdesc | iconv -f UTF-8 -t\n> > $emailcharset 2>/dev/null)\n> \n> Hmm, this generates a piece of e-mail whose subject line is in UTF-8\n> (without B/Q quoting) and message body is in totally different\n> encoding. Is it what mailers really want to see?\nHere you're right, too. Windows email clients may interpret Subject\nheader without B/Q quoting in its default Windows charset, and as far as\nit may contain non-English project description, so Subject would look\nugly. But I'll try to test with some clients.\n> \n> It almost seems backwards; converting the payload to UTF-8 and always\n> sending UTF-8 would be a simpler approach, methinks.\nSounds reasonable\n"}]}