try_partial_reuse(): convert to new revindex API
Remove another instance of direct revindex manipulation by calling 'pack_pos_to_offset()' instead (the caller here does not care about the index position of the object at position 'pos'). Note that we cannot just use the existing "offset" variable to store the value we get from pack_pos_to_offset(). It is incremented by unpack_object_header(), but we later need the original value. Since we'll no longer have revindex->offset to read it from, we'll store that in a separate variable ("header" since it points to the entry's header bytes). Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Jan 13, 2021 at 17:24 UTC
011f3fd5cdacc69e2ba2adf998656adcd2045a0f
1 file changed
+5
-8
pack-bitmap.c
+5
-8
@@ -1069,23 +1069,21 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git,
1069
struct bitmap *reuse,
1070
struct pack_window **w_curs)
1071
{
1072
- struct revindex_entry *revidx;
1073
- off_t offset;
1072
+ off_t offset, header;
1073
enum object_type type;
1074
unsigned long size;
1075
1076
if (pos >= bitmap_git->pack->num_objects)
1077
return; /* not actually in the pack */
1078
1080
- revidx = &bitmap_git->pack->revindex[pos];
1081
- offset = revidx->offset;
1079
+ offset = header = pack_pos_to_offset(bitmap_git->pack, pos);
1080
type = unpack_object_header(bitmap_git->pack, w_curs, &offset, &size);
1081
if (type < 0)
1082
return; /* broken packfile, punt */
1083
1084
if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA) {
1085
off_t base_offset;
1088
- int base_pos;
1086
+ uint32_t base_pos;
1087
1088
/*
1089
* Find the position of the base object so we can look it up
@@ -1096,11 +1094,10 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git,
1094
* more detail.
1095
*/
1096
base_offset = get_delta_base(bitmap_git->pack, w_curs,
1099
- &offset, type, revidx->offset);
1097
+ &offset, type, header);
1098
if (!base_offset)
1099
return;
1102
- base_pos = find_revindex_position(bitmap_git->pack, base_offset);
1103
- if (base_pos < 0)
1100
+ if (offset_to_pack_pos(bitmap_git->pack, base_offset, &base_pos) < 0)
1101
return;
1102
1103
/*