@@ -1201,7 +1201,7 @@ static void write_reused_pack(struct bitmapped_pack *reuse_packfile,
if (pos + offset >= reuse_packfile->bitmap_pos + reuse_packfile->bitmap_nr)
goto done;
- if (reuse_packfile->bitmap_pos) {
+ if (bitmap_is_midx(bitmap_git)) {
/*
* When doing multi-pack reuse on a
* non-preferred pack, translate bit positions
@@ -1209,7 +1209,7 @@ static void write_reused_pack(struct bitmapped_pack *reuse_packfile,
* pack-relative positions before attempting
* reuse.
*/
- struct multi_pack_index *m = reuse_packfile->from_midx;
+ struct multi_pack_index *m = bitmap_midx(bitmap_git);
uint32_t midx_pos;
off_t pack_ofs;
@@ -496,7 +496,6 @@ int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
MIDX_CHUNK_BITMAPPED_PACKS_WIDTH * local_pack_int_id +
sizeof(uint32_t));
bp->pack_int_id = pack_int_id;
- bp->from_midx = m;
return 0;
}
@@ -2326,7 +2326,6 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
packs[packs_nr].pack_int_id = pack_int_id;
packs[packs_nr].bitmap_nr = pack->num_objects;
packs[packs_nr].bitmap_pos = 0;
- packs[packs_nr].from_midx = bitmap_git->midx;
objects_nr = packs[packs_nr++].bitmap_nr;
}
@@ -2981,6 +2980,11 @@ int bitmap_is_midx(struct bitmap_index *bitmap_git)
return !!bitmap_git->midx;
}
+struct multi_pack_index *bitmap_midx(struct bitmap_index *bitmap_git)
+{
+ return bitmap_git->midx;
+}
+
const struct string_list *bitmap_preferred_tips(struct repository *r)
{
const struct string_list *dest;
@@ -60,7 +60,6 @@ struct bitmapped_pack {
uint32_t bitmap_pos;
uint32_t bitmap_nr;
- struct multi_pack_index *from_midx; /* MIDX only */
uint32_t pack_int_id; /* MIDX only */
};
@@ -157,6 +156,7 @@ char *midx_bitmap_filename(struct multi_pack_index *midx);
char *pack_bitmap_filename(struct packed_git *p);
int bitmap_is_midx(struct bitmap_index *bitmap_git);
+struct multi_pack_index *bitmap_midx(struct bitmap_index *bitmap_git);
const struct string_list *bitmap_preferred_tips(struct repository *r);
int bitmap_is_preferred_refname(struct repository *r, const char *refname);
This field was added in 41cd4b478f7 (pack-bitmap: tag bitmapped packs with their corresponding MIDX, 2024-08-27) in order to expose the bitmap's MIDX in order to translate bit positions correctly from within 'pack-objects' during pack-reuse (c.f., 125c32605ab (builtin/pack-objects.c: translate bit positions during pack-reuse, 2024-08-27) for more details). But another approach would have been to use the `->midx` field of the `struct bitmap_index *` directly, which feels clearer and avoids duplicating information. Unfortunately, we can't access that field directly since it is part of the `bitmap_index` structure which is static within the pack-bitmap.c compilation unit. So let's instead introduce a new function which returns that pointer to us, and replace the `from_midx` field with uses of that new function (which we call `bitmap_midx()` here). Signed-off-by: Taylor Blau <me@ttaylorr.com> --- builtin/pack-objects.c | 4 ++-- midx.c | 1 - pack-bitmap.c | 6 +++++- pack-bitmap.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-)