{"thread":{"id":"28441","subject":"[PATCH] format-patch: cover letter does not respect i18n.commitencoding","startedAt":"2011-09-20T08:26:17Z","lastAt":"2011-09-20T19:55:05Z","messageCount":3,"participants":["Alexey Shumkin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"175844","messageId":"1316507177-6403-1-git-send-email-zapped@mail.ru","threadId":"28441","inReplyTo":null,"subject":"[PATCH] format-patch: cover letter does not respect i18n.commitencoding","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-20T08:26:17Z","receivedAt":"2011-09-20T08:26:17Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"When we write a cover letter it is naturally enough to suppose\nthat we use the same encoding as we do commits in. So make\n\"format-patch --cover-letter\" to use i18n.commitencoding setting\nin \"Content-Type\" header of a cover letter instead of hard-coded \"UTF-8\".\nEspecially as cover letter contains shortlog and diffstat of patches\nwhich can contain author names and file names in i18n.commitencoding.\n\nSigned-off-by: Alexey Shumkin <zapped@mail.ru>\n---\n builtin/log.c |    4 ++--\n log-tree.c    |   10 ++++++----\n log-tree.h    |    3 ++-\n 3 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 5c2af59..6a4050c 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -769,7 +769,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \tstruct shortlog log;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint i;\n-\tconst char *encoding = \"UTF-8\";\n+\tconst char *encoding =  get_commit_output_encoding();\n \tstruct diff_options opts;\n \tint need_8bit_cte = 0;\n \tstruct commit *commit = NULL;\n@@ -806,7 +806,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \t}\n \n \tlog_write_email_headers(rev, head, &pp.subject, &pp.after_subject,\n-\t\t\t\t&need_8bit_cte);\n+\t\t\t\t&need_8bit_cte, get_commit_output_encoding());\n \n \tfor (i = 0; !need_8bit_cte && i < nr; i++)\n \t\tif (has_non_ascii(list[i]->buffer))\ndiff --git a/log-tree.c b/log-tree.c\nindex 39913d7..403aede 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -284,7 +284,8 @@ void get_patch_filename(struct commit *commit, int nr, const char *suffix,\n void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n \t\t\t     const char **subject_p,\n \t\t\t     const char **extra_headers_p,\n-\t\t\t     int *need_8bit_cte_p)\n+\t\t\t     int *need_8bit_cte_p,\n+\t\t\t     const char *encoding)\n {\n \tconst char *subject = NULL;\n \tconst char *extra_headers = opt->extra_headers;\n@@ -340,11 +341,12 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n \t\t\t \"format.\\n\"\n \t\t\t \"--%s%s\\n\"\n \t\t\t \"Content-Type: text/plain; \"\n-\t\t\t \"charset=UTF-8; format=fixed\\n\"\n+\t\t\t \"charset=%s; format=fixed\\n\"\n \t\t\t \"Content-Transfer-Encoding: 8bit\\n\\n\",\n \t\t\t extra_headers ? extra_headers : \"\",\n \t\t\t mime_boundary_leader, opt->mime_boundary,\n-\t\t\t mime_boundary_leader, opt->mime_boundary);\n+\t\t\t mime_boundary_leader, opt->mime_boundary,\n+\t\t\t encoding);\n \t\textra_headers = subject_buffer;\n \n \t\tget_patch_filename(opt->numbered_files ? NULL : commit, opt->nr,\n@@ -433,7 +435,7 @@ void show_log(struct rev_info *opt)\n \n \tif (opt->commit_format == CMIT_FMT_EMAIL) {\n \t\tlog_write_email_headers(opt, commit, &ctx.subject, &extra_headers,\n-\t\t\t\t\t&ctx.need_8bit_cte);\n+\t\t\t\t\t&ctx.need_8bit_cte, get_commit_output_encoding());\n \t} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);\n \t\tif (opt->commit_format != CMIT_FMT_ONELINE)\ndiff --git a/log-tree.h b/log-tree.h\nindex 5c4cf7c..ce0acf7 100644\n--- a/log-tree.h\n+++ b/log-tree.h\n@@ -17,7 +17,8 @@ void show_decorations(struct rev_info *opt, struct commit *commit);\n void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n \t\t\t     const char **subject_p,\n \t\t\t     const char **extra_headers_p,\n-\t\t\t     int *need_8bit_cte_p);\n+\t\t\t     int *need_8bit_cte_p,\n+\t\t\t     const char *encoding);\n void load_ref_decorations(int flags);\n \n #define FORMAT_PATCH_NAME_MAX 64\n-- \n1.7.6.3.4.gf71f\n"},{"id":"175881","messageId":"7v62kn6mqi.fsf@alter.siamese.dyndns.org","threadId":"28441","inReplyTo":"1316507177-6403-1-git-send-email-zapped@mail.ru","subject":"Re: [PATCH] format-patch: cover letter does not respect i18n.commitencoding","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-20T19:24:21Z","receivedAt":"2011-09-20T19:24:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexey Shumkin <zapped@mail.ru> writes:\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index 5c2af59..6a4050c 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -769,7 +769,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n>  \tstruct shortlog log;\n>  \tstruct strbuf sb = STRBUF_INIT;\n>  \tint i;\n> -\tconst char *encoding = \"UTF-8\";\n> +\tconst char *encoding =  get_commit_output_encoding();\n\nHmm, I have a feeling that this should use log output encoding. Am I\nmistaken?\n\nThe i18n.commitencoding variable is about the internal representation in\nthe object [*1*] that is to be converted from the encoding of the original\ne-mail message which could be different. i18n.logoutputencoding is to\nexternalize it [*2*].\n\n[Footnotes]\n\n*1* f1f909e (mailinfo: Use i18n.commitencoding, 2005-11-27)\n*2* a731ec5 (t3901: test \"format-patch | am\" pipe with i18n, 2007-01-13)\n"},{"id":"175888","messageId":"20110920235505.26fb6501@zappedws","threadId":"28441","inReplyTo":"7v62kn6mqi.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] format-patch: cover letter does not respect i18n.commitencoding","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-20T19:55:05Z","receivedAt":"2011-09-20T19:55:05Z","isPatch":true,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"> Alexey Shumkin <zapped@mail.ru> writes:\n> \n> > diff --git a/builtin/log.c b/builtin/log.c\n> > index 5c2af59..6a4050c 100644\n> > --- a/builtin/log.c\n> > +++ b/builtin/log.c\n> > @@ -769,7 +769,7 @@ static void make_cover_letter(struct rev_info\n> > *rev, int use_stdout, struct shortlog log;\n> >  \tstruct strbuf sb = STRBUF_INIT;\n> >  \tint i;\n> > -\tconst char *encoding = \"UTF-8\";\n> > +\tconst char *encoding =  get_commit_output_encoding();\n> \n> Hmm, I have a feeling that this should use log output encoding. Am I\n> mistaken?\nOooh! I made a mistake. I'm sorry\n\nget_log_output_encoding must be used instead, yes\n\n> The i18n.commitencoding variable is about the internal representation\n> in the object [*1*] that is to be converted from the encoding of the\n> original e-mail message which could be different.\n> i18n.logoutputencoding is to externalize it [*2*].\n> \n> [Footnotes]\n> \n> *1* f1f909e (mailinfo: Use i18n.commitencoding, 2005-11-27)\n> *2* a731ec5 (t3901: test \"format-patch | am\" pipe with i18n,\n> 2007-01-13)\n> \n"}]}