summaryrefslogtreecommitdiff
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-01-13 22:24:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-14 05:53:46 (GMT)
commit011f3fd5cdacc69e2ba2adf998656adcd2045a0f (patch)
tree7be41875517928c075b977c08ab6e3039daea23d /pack-bitmap.c
parenta78a90324d1c5ccba2ab46cb70573518dd6eeade (diff)
downloadgit-011f3fd5cdacc69e2ba2adf998656adcd2045a0f.zip
git-011f3fd5cdacc69e2ba2adf998656adcd2045a0f.tar.gz
git-011f3fd5cdacc69e2ba2adf998656adcd2045a0f.tar.bz2
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>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 89a528a..1fdf7ce 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1069,23 +1069,21 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git,
struct bitmap *reuse,
struct pack_window **w_curs)
{
- struct revindex_entry *revidx;
- off_t offset;
+ off_t offset, header;
enum object_type type;
unsigned long size;
if (pos >= bitmap_git->pack->num_objects)
return; /* not actually in the pack */
- revidx = &bitmap_git->pack->revindex[pos];
- offset = revidx->offset;
+ offset = header = pack_pos_to_offset(bitmap_git->pack, pos);
type = unpack_object_header(bitmap_git->pack, w_curs, &offset, &size);
if (type < 0)
return; /* broken packfile, punt */
if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA) {
off_t base_offset;
- int base_pos;
+ uint32_t base_pos;
/*
* 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,
* more detail.
*/
base_offset = get_delta_base(bitmap_git->pack, w_curs,
- &offset, type, revidx->offset);
+ &offset, type, header);
if (!base_offset)
return;
- base_pos = find_revindex_position(bitmap_git->pack, base_offset);
- if (base_pos < 0)
+ if (offset_to_pack_pos(bitmap_git->pack, base_offset, &base_pos) < 0)
return;
/*