]> git.ipfire.org Git - thirdparty/git.git/commit
packed-backend: extract snapshot allocation in `load_contents`
authorshejialuo <shejialuo@gmail.com>
Wed, 14 May 2025 15:50:35 +0000 (23:50 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 May 2025 19:32:58 +0000 (12:32 -0700)
commita0dee3f74b4f42076b7c23ca6d9aca61ed064e82
tree90813e4d8cd58fb0c44f3163bb1bc5cfe0ed5cdc
parent784ceccb91b82dc8a2c69ddd6f1f5ccc2e2f96f2
packed-backend: extract snapshot allocation in `load_contents`

"load_contents" would choose which way to load the content of the
"packed-refs". However, we cannot directly use this function when
checking the consistency due to we don't want to open the file. And we
also need to reuse the logic to avoid causing repetition.

Let's create a new helper function "allocate_snapshot_buffer" to extract
the snapshot allocation logic in "load_contents" and update the
"load_contents" to align with the behavior.

Suggested-by: Jeff King <peff@peff.net>
Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/packed-backend.c