git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Vajna <vmiklos@frugalware.org>
To: git@vger.kernel.org
Subject: [RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting
Date: Fri, 20 Feb 2009 02:12:38 +0100	[thread overview]
Message-ID: <1235092358-6895-1-git-send-email-vmiklos@frugalware.org> (raw)

As git-shortlog can be used as a filter as well, we do not really have
the encoding info to do a reencode_string(), but in case
i18n.logOutputEncoding is set, we can try to convert to the given value
from utf-8.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

It was just annoying for me that git log respected
i18n.logOutputEncoding, but I still saw unencoded utf-8 in git-shortlog
output. This patches fixes my problem.

Yes, I'm aware that hardwiring that utf-8 value is a bit hackish. But at
least this way the output encoding is correct in case the original
encoding is utf-8, which is true in most cases.

Or do you have a better idea?

 builtin-shortlog.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index badd912..cd95858 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -45,6 +45,7 @@ static void insert_one_record(struct shortlog *log,
 	const char *eol;
 	const char *boemail, *eoemail;
 	struct strbuf subject = STRBUF_INIT;
+	char *encoded_name = NULL;
 
 	boemail = strchr(author, '<');
 	if (!boemail)
@@ -84,7 +85,12 @@ static void insert_one_record(struct shortlog *log,
 		snprintf(namebuf + len, room, " <%.*s>", maillen, emailbuf);
 	}
 
-	item = string_list_insert(namebuf, &log->list);
+	if (git_log_output_encoding)
+		encoded_name = reencode_string(namebuf, git_log_output_encoding, "utf-8");
+	if (!encoded_name)
+		encoded_name = xstrdup(namebuf);
+	item = string_list_insert(encoded_name, &log->list);
+	free(encoded_name);
 	if (item->util == NULL)
 		item->util = xcalloc(1, sizeof(struct string_list));
 
-- 
1.6.1.3

             reply	other threads:[~2009-02-20  1:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20  1:12 Miklos Vajna [this message]
2009-03-22 11:34 ` [RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting Miklos Vajna
2009-03-22 19:26   ` Junio C Hamano
2009-03-22 19:47     ` Miklos Vajna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1235092358-6895-1-git-send-email-vmiklos@frugalware.org \
    --to=vmiklos@frugalware.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).