Subject: Re: [PATCH] trailer: change strbuf in-place in unfold_value()

From: Jeff King <[email-masked]>
Date: Fri, 15 May 2026 00:47:03 -0400

On Thu, May 14, 2026 at 08:40:56PM +0200, René Scharfe wrote:

> Avoid an allocation by doing s/\n\s*/ /g (replacing NL and any following
> whitespace with a SP) right in the strbuf instead of copying the result
> to a temporary one and swapping them in the end.  We can safely do that
> because the replacement is never longer than the original string.
>
> [...]
>
> Inspired by https://lore.kernel.org/git/[email-masked]/

Cute. Modulo the issue raised by Ramsay, this looks correct to me. In
the discussion you referenced I was mostly expecting people to find
spots where the solution would be to just remove the strbuf_grow() call.
This one is quite a bit trickier, and I am glad to have somebody careful
looking at it. ;)

-Peff