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

[RFC/PATCH] git-shortlog: respect i18n.logOutputEncoding config setting

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Feb 20, 2009, 01:12 UTC
Message-ID
<1235092358-6895-1-git-send-email-vmiklos@frugalware.org>

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
Next: Miklos Vajna
Message 1 of 4 in “git-shortlog: respect i18n.logOutputEncoding config setting”
  1. git-shortlog: respect i18n.logOutputEncoding config settingMiklos Vajna, Feb 20, 2009
  2. Miklos VajnaMar 22, 2009
  3. Junio C HamanoMar 22, 2009
  4. Miklos VajnaMar 22, 2009

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.