]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit: name UTF-8 function appropriately
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 27 Apr 2026 22:18:33 +0000 (22:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Apr 2026 00:51:11 +0000 (09:51 +0900)
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>
commit.c

index 80d8d078757dbc4fd534bc038f4774850e57bf6c..790dd2faed77e07ddb12d3ab6fbdc16a5759ed7b 100644 (file)
--- 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) {