]> Kevux Git Server - rit/commit
packfile: factor out --pack_header argument parsing
authorJeff King <peff@peff.net>
Sun, 19 Jan 2025 13:23:37 +0000 (08:23 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Jan 2025 16:42:55 +0000 (08:42 -0800)
commit798e0f451661f81f4568dce4033cf1c9076f224f
tree5b81233fbf9956dda141e108741a47288e75aeaf
parent2105064b10758c9032b94112276e8d3eb5718a2f
packfile: factor out --pack_header argument parsing

Both index-pack and unpack-objects accept a --pack_header argument. This
is an undocumented internal argument used by receive-pack and fetch to
pass along information about the header of the pack, which they've
already read from the incoming stream.

In preparation for a bugfix, let's factor the duplicated code into a
common helper.

The callers are still responsible for identifying the option. While this
could likewise be factored out, it is more flexible this way (e.g., if
they ever started using parse-options and wanted to handle both the
stuck and unstuck forms).

Likewise, the callers are responsible for reporting errors, though they
both just call die(). I've tweaked unpack-objects to match index-pack in
marking the error for translation.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c
builtin/unpack-objects.c
packfile.c
packfile.h