commit: name UTF-8 function appropriately

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Apr 27, 2026 at 22:18 UTC 1ddc0481cfb744d51e235a8cccf97d4afb498743
1 file changed +3 -3
commit.c
+3 -3
@@ -1637,12 +1637,12 @@ static int find_invalid_utf8(const char *buf, int len)
1637 }
1638
1639 /*
1640 - * This verifies that the buffer is in proper utf8 format.
1640 + * This ensures that the buffer is in proper utf8 format.
1641 *
1642 * If it isn't, it assumes any non-utf8 characters are Latin1,
1643 * and does the conversion.
1644 */
1645 -static int verify_utf8(struct strbuf *buf)
1645 +static int ensure_utf8(struct strbuf *buf)
1646 {
1647 int ok = 1;
1648 long pos = 0;
@@ -1819,7 +1819,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
1819 }
1820
1821 /* And check the encoding. */
1822 - if (encoding_is_utf8 && (!verify_utf8(&buffer) || !verify_utf8(&compat_buffer)))
1822 + if (encoding_is_utf8 && (!ensure_utf8(&buffer) || !ensure_utf8(&compat_buffer)))
1823 fprintf(stderr, _(commit_utf8_warn));
1824
1825 if (r->compat_hash_algo) {