diff mbox series

[04/11] pack-bitmap.c: compare `base_offset` to `delta_obj_offset`

Message ID bc5ff77f63b42dbea70b12f736e48f95fe8d6cf3.1728505840.git.me@ttaylorr.com (mailing list archive)
State New
Headers show
Series pack-bitmap: convert offset to ref deltas where possible | expand

Commit Message

Taylor Blau Oct. 9, 2024, 8:31 p.m. UTC
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 mbox series

Patch

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)