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

Re: [PATCH v2] http-backend: drop strbuf pre-sizing from get_info_packs()

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2026, 15:24 UTC
Message-ID
<xmqqy0asn6j0.fsf@gitster.g>
In-Reply-To
<avqi2Jpd-QT5iNU9@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 11 quoted lines
>> This pre-sizing dates back to 2f4038ab33 (Git-aware CGI to provide dumb
>> HTTP transport, 2009-10-30): `53` assumes the length of a SHA-1
>> "P pack-<hex>.pack\n" line (under-counting the 77-byte lines in SHA-256
>> repositories), and `cnt * 53 + 2` uses unchecked arithmetic.
>>  ...
> Yeah, that's a much more convincing message. The other angle that this
> is missing a bit is that giving a size hint ensures that we allocate
> exactly as many bytes as we need. But that shouldn't matter in the
> general case, and if you have to allocate gigabytes of memory to store
> the list of packfiles... well, then you really have bigger problems to
> worry about.

Yeah, miscounting the preallocation is not a bug and just doing pointless work. I agree with you that for the purpose of sizing strbuf, you have a larger issue if you have to worry about overflowing arithmetic.

> So I think this version is good enough, thanks!
Thanks.
Previous: Patrick Steinhardt
Message 6 of 6 in “http-backend: drop strbuf pre-sizing from get_info_packs()”
  1. http-backend: drop strbuf pre-sizing from get_info_packs()Yusuke Hayashi via B4 Relay, Nov 13, 2026
  2. Patrick SteinhardtNov 13, 2026
  3. Yusuke HayashiNov 15, 2026
  4. http-backend: drop strbuf pre-sizing from get_info_packs()Yusuke Hayashi via B4 Relay, Nov 15, 2026
  5. Patrick SteinhardtNov 16, 2026
  6. Junio C HamanoNov 16, 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.