[PATCH 04/11] pack-bitmap.c: compare `base_offset` to `delta_obj_offset`
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 9, 2024, 20:31 UTC
- Message-ID
- <bc5ff77f63b42dbea70b12f736e48f95fe8d6cf3.1728505840.git.me@ttaylorr.com>
- In-Reply-To
- <cover.1728505840.git.me@ttaylorr.com>
When comparing the offsets of either half of a delta/base-pair, we compare `base_offset` to `offset`.
There is nothing functionally wrong with that comparison, but it is slightly confusing, since `offset` points to just after the delta object's type header in the pack, whereas `base_offset` points to the beginning of the header.
In practice, that distinction does not matter, and it is perfectly fine to compare base_offset to offset.
But we already make a copy of `offset` before it is moved forward by calling the function `unpack_object_header()`. So let's use that copy (which points at the beginning of the delta object's header) in the comparison so that we are comparing like quantities.
Signed-off-by: Taylor Blau <me@ttaylorr.com> --- pack-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pack-bitmap.c b/pack-bitmap.c index faabc0ba0e9..3e1034cabf3 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -2117,7 +2117,7 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git, * position, since the bits are ordered by their * positions within the pack. */ - if (base_offset >= offset) + if (base_offset >= delta_obj_offset) return 0; if (offset_to_pack_pos(pack->p, base_offset, &base_bitmap_pos) < 0)
-- 2.47.0.11.g487258bca34