{"thread":{"id":"17910","subject":"[RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting","startedAt":"2009-02-20T01:12:38Z","lastAt":"2009-03-22T19:47:08Z","messageCount":4,"participants":["Miklos Vajna","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"105541","messageId":"1235092358-6895-1-git-send-email-vmiklos@frugalware.org","threadId":"17910","inReplyTo":null,"subject":"[RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-02-20T01:12:38Z","receivedAt":"2009-02-20T01:12:38Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"As git-shortlog can be used as a filter as well, we do not really have\nthe encoding info to do a reencode_string(), but in case\ni18n.logOutputEncoding is set, we can try to convert to the given value\nfrom utf-8.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nIt was just annoying for me that git log respected\ni18n.logOutputEncoding, but I still saw unencoded utf-8 in git-shortlog\noutput. This patches fixes my problem.\n\nYes, I'm aware that hardwiring that utf-8 value is a bit hackish. But at\nleast this way the output encoding is correct in case the original\nencoding is utf-8, which is true in most cases.\n\nOr do you have a better idea?\n\n builtin-shortlog.c |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex badd912..cd95858 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -45,6 +45,7 @@ static void insert_one_record(struct shortlog *log,\n \tconst char *eol;\n \tconst char *boemail, *eoemail;\n \tstruct strbuf subject = STRBUF_INIT;\n+\tchar *encoded_name = NULL;\n \n \tboemail = strchr(author, '<');\n \tif (!boemail)\n@@ -84,7 +85,12 @@ static void insert_one_record(struct shortlog *log,\n \t\tsnprintf(namebuf + len, room, \" <%.*s>\", maillen, emailbuf);\n \t}\n \n-\titem = string_list_insert(namebuf, &log->list);\n+\tif (git_log_output_encoding)\n+\t\tencoded_name = reencode_string(namebuf, git_log_output_encoding, \"utf-8\");\n+\tif (!encoded_name)\n+\t\tencoded_name = xstrdup(namebuf);\n+\titem = string_list_insert(encoded_name, &log->list);\n+\tfree(encoded_name);\n \tif (item->util == NULL)\n \t\titem->util = xcalloc(1, sizeof(struct string_list));\n \n-- \n1.6.1.3\n"},{"id":"108892","messageId":"20090322113438.GK27459@genesis.frugalware.org","threadId":"17910","inReplyTo":"1235092358-6895-1-git-send-email-vmiklos@frugalware.org","subject":"Re: [RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-03-22T11:34:38Z","receivedAt":"2009-03-22T11:34:38Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Fri, Feb 20, 2009 at 02:12:38AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> As git-shortlog can be used as a filter as well, we do not really have\n> the encoding info to do a reencode_string(), but in case\n> i18n.logOutputEncoding is set, we can try to convert to the given value\n> from utf-8.\n\nShould I resend this patch without RFC in the subject?\n\nI just hit this bug again today, then realised that I already posted a\npatch for this problem. :-)\n"},{"id":"108923","messageId":"7v7i2h5pfh.fsf@gitster.siamese.dyndns.org","threadId":"17910","inReplyTo":"20090322113438.GK27459@genesis.frugalware.org","subject":"Re: [RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-22T19:26:58Z","receivedAt":"2009-03-22T19:26:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> On Fri, Feb 20, 2009 at 02:12:38AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:\n>> As git-shortlog can be used as a filter as well, we do not really have\n>> the encoding info to do a reencode_string(), but in case\n>> i18n.logOutputEncoding is set, we can try to convert to the given value\n>> from utf-8.\n\nIt is unclear what you want to say in these for lines.  Do you mean \"when\nused to generate logs by itself this patch improves the behaviour by\nmaking the output consistent with what \"git log\" does, but it does the\nsame mangling when used as a filter without knowing the log encoding and\npotentially screw people over who have been depending on it not to convert\nthe encoding\"?  Or something else?\n"},{"id":"108925","messageId":"20090322194708.GP27459@genesis.frugalware.org","threadId":"17910","inReplyTo":"7v7i2h5pfh.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-03-22T19:47:08Z","receivedAt":"2009-03-22T19:47:08Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Sun, Mar 22, 2009 at 12:26:58PM -0700, Junio C Hamano <gitster@pobox.com> wrote:\n> It is unclear what you want to say in these for lines.  Do you mean \"when\n> used to generate logs by itself this patch improves the behaviour by\n> making the output consistent with what \"git log\" does, but it does the\n> same mangling when used as a filter without knowing the log encoding and\n> potentially screw people over who have been depending on it not to convert\n> the encoding\"?  Or something else?\n\nNot exactly - let me rephrase:\n\nNormally we can do a reencode_string() because we know the encoding of\nthe commit and we know the wished output encoding.  Given that\ngit-shortlog can be a filter as well, we don't know the encoding of the\ninput, but we know the wished output encoding. So what we can do is to\n_try_ to encode from utf8 to the wished encoding, and if that fails,\njust don't convert anything. The result is correct, because:\n\n1) If git-shortlog is a filter, then git-log already does the encoding,\nthe encoding will fail in git-shortlog so the original input will be\nshown.\n\n2) In the other case git-shoftlog can just do the converion.\n\nAt least I tested the case with utf8 author names and a latin2 terminal\nand both the 'git log rev.. | git shortlog' and the 'git shortlog rev..'\noutput was correct, while git.git's master shows the correct output only\nin the first case.\n"}]}