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

Re: [PATCH 2/2] commit: sign commit after mutating buffer

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 24, 2026, 20:17 UTC
Message-ID
<aevPxrN3xWq8SP71@fruit.crustytoothpaste.net>
In-Reply-To
<CABPp-BEd9saiMWVdcSaZBHqGreshpA=fGZc4AvYkoU=swSSuxA@mail.gmail.com>
On 2026-04-22 at 15:10:29, Elijah Newren wrote:
Show 29 quoted lines
> On Mon, Apr 20, 2026 at 3:14 PM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> > diff --git a/commit.c b/commit.c
> > index 790dd2faed..bc41859be1 100644
> > --- a/commit.c
> > +++ b/commit.c
> > @@ -1747,6 +1747,11 @@ int commit_tree_extended(const char *msg, size_t msg_len,
> >                 oidcpy(&parent_buf[i++], &p->item->object.oid);
> >
> >         write_commit_tree(&buffer, msg, msg_len, tree, parent_buf, nparents, author, committer, extra);
> > +
> > +       /* And check the encoding. */
> > +       if (encoding_is_utf8 && !ensure_utf8(&buffer))
> > +               fprintf(stderr, _(commit_utf8_warn));
> > +
> >         if (sign_commit && sign_buffer(&buffer, &sig, sign_commit,
> >                                        SIGN_BUFFER_USE_DEFAULT_KEY)) {
> >                 result = -1;
> > @@ -1780,6 +1785,9 @@ int commit_tree_extended(const char *msg, size_t msg_len,
> >                 free_commit_extra_headers(compat_extra);
> >                 free(mapped_parents);
> >
> > +               if (encoding_is_utf8 && !ensure_utf8(&compat_buffer))
> > +                       fprintf(stderr, _(commit_utf8_warn));
> > +
> 
> So the users might see "commit message did not conform to UTF-8..."
> twice? (Isn't compat_buffer likely to have invalid UTF-8 whenever
> buffer does?)  Do we want to avoid that double printing?
Yeah, I'll fix that in v2.
> Did the change in this patch also fix a short-circuiting error?
> Previously, when both buffers had invalid UTF-8, we'd only call
> ensure_utf8() on the first one and fix it, and then short-circuit and
> not handle compat_buffer, right?
I believe it did, yes.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Elijah NewrenNext: Elijah Newren
Message 6 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.