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

[PATCH 1/2] commit: name UTF-8 function appropriately

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 20, 2026, 22:14 UTC
Message-ID
<20260420221425.2763661-1-sandals@crustytoothpaste.net>
In-Reply-To
<aeakf0xcjSteTMZp@fruit.crustytoothpaste.net>

We have a function named verify_utf8, but it does more than verify, it modifies the buffer if it is not UTF-8. This is different from what most people would expect, so call the function ensure_utf8, since it mutates the buffer in some cases.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 commit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/commit.c b/commit.c
index 80d8d07875..790dd2faed 100644
--- a/commit.c
+++ b/commit.c
@@ -1637,12 +1637,12 @@ static int find_invalid_utf8(const char *buf, int len)
 }
 
 /*
- * This verifies that the buffer is in proper utf8 format.
+ * This ensures that the buffer is in proper utf8 format.
  *
  * If it isn't, it assumes any non-utf8 characters are Latin1,
  * and does the conversion.
  */
-static int verify_utf8(struct strbuf *buf)
+static int ensure_utf8(struct strbuf *buf)
 {
 	int ok = 1;
 	long pos = 0;
@@ -1819,7 +1819,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
 	}
 
 	/* And check the encoding. */
-	if (encoding_is_utf8 && (!verify_utf8(&buffer) || !verify_utf8(&compat_buffer)))
+	if (encoding_is_utf8 && (!ensure_utf8(&buffer) || !ensure_utf8(&compat_buffer)))
 		fprintf(stderr, _(commit_utf8_warn));
 
 	if (r->compat_hash_algo) {
Previous: brian m. carlsonNext: brian m. carlson
Message 3 of 13 in “[BUG] v2.45+: git commit -S invalidates signature for non-UTF-8 messages”
  1. Kushal DasApr 20, 2026
  2. brian m. carlsonApr 20, 2026
  3. 1/2 commit: name UTF-8 function appropriatelybrian m. carlson, Apr 20, 2026
  4. 2/2 commit: sign commit after mutating bufferbrian m. carlson, Apr 20, 2026
  5. Elijah NewrenApr 22, 2026
  6. brian m. carlsonApr 24, 2026
  7. Elijah NewrenApr 22, 2026
  8. Kushal DasApr 21, 2026
  9. brian m. carlsonApr 21, 2026
  10. D. Ben KnobleApr 22, 2026
  11. 1/2 commit: name UTF-8 function appropriatelybrian m. carlson, Apr 27, 2026
  12. 2/2 commit: sign commit after mutating bufferbrian m. carlson, Apr 27, 2026
  13. Junio C HamanoMay 12, 2026

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.