Re: [PATCH 09/12] pkt-line: make packet_reader.line non-const
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 1, 2026, 22:18 UTC
- Message-ID
- <xmqq4iluuxxg.fsf@gitster.g>
- In-Reply-To
- <20260331235136.GI2328529@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> The "line" member of a packet_reader struct is marked as const. This > kind of makes sense, because it's not its own allocated buffer that > should be freed, and we often use const to indicate that.
This is interesting. Once we go down this path, will we rethink the use of "const" as "not ours" hint (which I always found confusing)?
Show 10 quoted lines
> We can fix it by marking "line" as non-const, as well as a few > intermediate variables (like "head" in the above example). Note that by > itself, switching to a non-const variable would cause problems with this > line in send-pack.c: > > if (!skip_prefix(reader->line, "unpack ", &reader->line)) > > But due to our skip_prefix() magic introduced in the previous commit, > this compiles fine (both the in and out-parameters are non-const, so we > know it is safe).
OK.