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

Re: [PATCH] Reencode committer info to utf-8 before formatting mail header

From
Junio C Hamano <junkio@cox.net>
Date
Jan 13, 2007, 01:43 UTC
Message-ID
<7vmz4nog5b.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vr6tzogp4.fsf@assigned-by-dhcp.cox.net>

Side note. The previous patch does not help if your commit were made in non UTF-8 with not too recent git; the code assumes that commit messages without the new "encoding" headers are in UTF-8.

We might want to help transitioning people by doing something like this on top of the previous patch. Then when dealing with an ancient commit (sorry, I am not saying commits older than 3 weeks are ancient -- but it will be 6 months from now ;-), you can override that default by setting an environment variable.

---
diff --git a/commit.c b/commit.c
index 9b2b842..a1b5705 100644
--- a/commit.c
+++ b/commit.c
@@ -692,8 +692,12 @@ static char *logmsg_reencode(const struct commit *commit,
 	if (!*output_encoding)
 		return NULL;
 	encoding = get_header(commit, "encoding");
-	if (!encoding)
-		encoding = utf8;
+	if (!encoding) {
+		if (getenv("GIT_OLD_COMMIT_ENCODING"))
+			encoding = strdup(getenv("GIT_OLD_COMMIT_ENCODING"));
+		else
+			encoding = utf8;
+	}
 	if (!strcmp(encoding, output_encoding))
 		out = strdup(commit->buffer);
 	else
Previous: Junio C HamanoNext: Johannes Schindelin
Message 4 of 18 in “Reencode committer info to utf-8 before formatting mail header”
  1. Reencode committer info to utf-8 before formatting mail headerDavid Kågedal, Jan 12, 2007
  2. Junio C HamanoJan 12, 2007
  3. Junio C HamanoJan 13, 2007
  4. Junio C HamanoJan 13, 2007
  5. Johannes SchindelinJan 13, 2007
  6. Junio C HamanoJan 13, 2007
  7. David KågedalJan 15, 2007
  8. Johannes SchindelinJan 16, 2007
  9. David KågedalJan 16, 2007
  10. Robin RosenbergJan 13, 2007
  11. Junio C HamanoJan 13, 2007
  12. David KågedalJan 15, 2007
  13. Alex RiesenJan 13, 2007
  14. Horst H. von BrandJan 14, 2007
  15. Alex RiesenJan 14, 2007
  16. Junio C HamanoJan 13, 2007
  17. David KågedalJan 15, 2007
  18. David KågedalJan 15, 2007

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.