]> git.ipfire.org Git - thirdparty/git.git/commit
pack-objects: support reuse with `--no-ref-delta`
authorTaylor Blau <ttaylorr@openai.com>
Mon, 13 Jul 2026 01:12:02 +0000 (18:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Jul 2026 01:39:03 +0000 (18:39 -0700)
commitaca978d38668f74766e14cd75b4461ae356e47bb
tree4b3809b10b869327391a05845274a491dd22bbc6
parent5e4971b28ec3953094dbfe874fdd7baa7f8d1d47
pack-objects: support reuse with `--no-ref-delta`

The previous commit disables delta- and bitmap-reuse entirely whenever
pack-objects is given '--no-ref-delta' for the sake of simplicity. This
is overly pessimistic.

When '--delta-base-offset' is also given, delta reuse can remain
enabled. A reused delta whose base is written earlier in the output can
be encoded as an `OFS_DELTA`, even when its source copy was encoded as a
`REF_DELTA`.

Preferred bases and external thin-pack bases are different: neither
appears in the output, so deltas against either still require encoding
the object as a `REF_DELTA`, and thus cannot be reused.

Without '--delta-base-offset', delta reuse remains disabled, since no
delta representation remains.

Bitmap reuse follows a different path, since selected entries may be
copied without passing through the code which chooses a delta
representation. When given '--no-ref-delta', we must inspect candidate
objects individually, and leave `REF_DELTA` entries to the normal object
path outside of pack-reuse.

We must likewise avoid the special-case for reusing either the single or
preferred pack corresponding to the bitmap by whole `eword_t`'s at a
time.

Signed-off-by: Taylor Blau <ttaylorr@openai.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
pack-bitmap.c
pack-bitmap.h
t/t5300-pack-object.sh
t/t5332-multi-pack-reuse.sh