From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Kushal Das <kushal@sunet.se>
Subject: [PATCH 1/2] commit: name UTF-8 function appropriately
Date: Mon, 20 Apr 2026 22:14:24 +0000 [thread overview]
Message-ID: <20260420221425.2763661-1-sandals@crustytoothpaste.net> (raw)
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) {
next prev parent reply other threads:[~2026-04-20 22:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 8:59 [BUG] v2.45+: git commit -S invalidates signature for non-UTF-8 messages Kushal Das
2026-04-20 22:11 ` brian m. carlson
2026-04-20 22:14 ` brian m. carlson [this message]
2026-04-20 22:14 ` [PATCH 2/2] commit: sign commit after mutating buffer brian m. carlson
2026-04-22 15:10 ` Elijah Newren
2026-04-24 20:17 ` brian m. carlson
2026-04-22 15:10 ` [PATCH 1/2] commit: name UTF-8 function appropriately Elijah Newren
2026-04-21 7:39 ` [BUG] v2.45+: git commit -S invalidates signature for non-UTF-8 messages Kushal Das
2026-04-21 22:13 ` brian m. carlson
2026-04-22 18:13 ` D. Ben Knoble
2026-04-27 22:18 ` [PATCH v2 1/2] commit: name UTF-8 function appropriately brian m. carlson
2026-04-27 22:18 ` [PATCH v2 2/2] commit: sign commit after mutating buffer brian m. carlson
2026-05-12 5:54 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260420221425.2763661-1-sandals@crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kushal@sunet.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox