Re: [PATCH 4/6] builtin/receive-pack: report unpack errors via strbuf
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Aug 7, 2026, 15:36 UTC
- Message-ID
- <anX6w0tFV6pCu1ux@denethor>
- In-Reply-To
- <anWDTwCwMn5wEdIQ@pks.im>
On 26/08/07 09:03AM, Patrick Steinhardt wrote:
Show 9 quoted lines
> On Thu, Aug 06, 2026 at 04:38:57PM -0500, Justin Tobler wrote: > > @@ -2551,13 +2559,13 @@ static void update_shallow_info(struct command *commands, > > free(ref_status); > > } > > > > -static void report(struct command *commands, const char *unpack_status) > > +static void report(struct command *commands, struct strbuf *unpack_status) > > Should we mark this parameter as `const`?
Yes, will do in the next version.
Show 9 quoted lines
> > > @@ -2575,14 +2583,14 @@ static void report(struct command *commands, const char *unpack_status) > > strbuf_release(&buf); > > } > > > > -static void report_v2(struct command *commands, const char *unpack_status) > > +static void report_v2(struct command *commands, struct strbuf *unpack_status) > > And here, as well?
Will do.
Show 10 quoted lines
> > @@ -2711,8 +2719,8 @@ int cmd_receive_pack(int argc,
> > PACKET_READ_DIE_ON_ERR_PACKET);
> >
> > if ((commands = read_head_info(&reader, &shallow))) {
> > - const char *unpack_status = NULL;
> > struct string_list push_options = STRING_LIST_INIT_DUP;
> > + struct strbuf unpack_status = STRBUF_INIT;
>
> Can't we reuse this buffer and reset it on every run to save some memory
> allocations?Good suggestion. I'll lift this up in the next version so we can reuse it for each iteration.
-Justin