]> git.ipfire.org Git - thirdparty/git.git/commit
http: avoid concurrent appends to partial packs
authorTed Nyman <tnyman@openai.com>
Mon, 27 Jul 2026 00:28:41 +0000 (17:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Jul 2026 19:57:20 +0000 (12:57 -0700)
commit5e855d9b426dd01552ecbfb47062b90fe53b3df5
tree562f4c85177044694971b1432889c0304a2514e3
parent85f4f04f820c9aa6cfdfb4594ceb9b41515a8245
http: avoid concurrent appends to partial packs

Pack requests stage downloads in a predictable partial-pack file so an
interrupted transfer can be resumed. Both packfile URI and ordinary dumb
HTTP requests use this staging path. Opening it in append mode forces
each write to the current end of the file, so concurrent responses can
append duplicate data and corrupt the pack.

Open the partial pack read-write without O_APPEND and seek once to its
current end. Each downloader then retains the offset matching the Range
it requested. Because the staging key must uniquely identify immutable
pack contents, overlapping responses write the same bytes at the same
offsets instead of extending the file with duplicate data.

Duplicate the staging descriptor for index-pack instead of reopening the
path after closing the stream. Another downloader may unlink the staging
path before indexing begins, but index-pack can still read the retained
descriptor.

Exercise resumed transfers and overlapping 200 and 206 responses, and
clarify the staging-key documentation.

Signed-off-by: Ted Nyman <tnyman@openai.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-http-fetch.adoc
http.c
t/t5550-http-fetch-dumb.sh