packfile: drop repository parameter from `packed_object_info()`

The function `packed_object_info()` takes a packfile and offset and returns the object info for the corresponding object. Despite these two parameters though it also takes a repository pointer. This is redundant information though, as `struct packed_git` already has a repository pointer that is always populated. Drop the redundant parameter. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 12, 2026 at 10:00 UTC 12d3b58b5552750f351ded7166b347446d9543f3
6 files changed +10 -13
builtin/cat-file.c
+1 -2
@@ -487,8 +487,7 @@ static void batch_object_write(const char *obj_name,
487 data->info.sizep = &data->size;
488
489 if (pack)
490 - ret = packed_object_info(the_repository, pack,
491 - offset, &data->info);
490 + ret = packed_object_info(pack, offset, &data->info);
491 else
492 ret = odb_read_object_info_extended(the_repository->objects,
493 &data->oid, &data->info,
builtin/pack-objects.c
+2 -2
@@ -2411,7 +2411,7 @@ static void drop_reused_delta(struct object_entry *entry)
2411
2412 oi.sizep = &size;
2413 oi.typep = &type;
2414 - if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2414 + if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2415 /*
2416 * We failed to get the info from this pack for some reason;
2417 * fall back to odb_read_object_info, which may find another copy.
@@ -3748,7 +3748,7 @@ static int add_object_entry_from_pack(const struct object_id *oid,
3748 struct object_info oi = OBJECT_INFO_INIT;
3749
3750 oi.typep = &type;
3751 - if (packed_object_info(the_repository, p, ofs, &oi) < 0) {
3751 + if (packed_object_info(p, ofs, &oi) < 0) {
3752 die(_("could not get type of object %s in pack %s"),
3753 oid_to_hex(oid), p->pack_name);
3754 } else if (type == OBJ_COMMIT) {
commit-graph.c
+1 -1
@@ -1499,7 +1499,7 @@ static int add_packed_commits(const struct object_id *oid,
1499 display_progress(ctx->progress, ++ctx->progress_done);
1500
1501 oi.typep = &type;
1502 - if (packed_object_info(ctx->r, pack, offset, &oi) < 0)
1502 + if (packed_object_info(pack, offset, &oi) < 0)
1503 die(_("unable to get type of object %s"), oid_to_hex(oid));
1504
1505 if (type != OBJ_COMMIT)
pack-bitmap.c
+1 -2
@@ -1876,8 +1876,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
1876 ofs = pack_pos_to_offset(pack, pos);
1877 }
1878
1879 - if (packed_object_info(bitmap_repo(bitmap_git), pack, ofs,
1880 - &oi) < 0) {
1879 + if (packed_object_info(pack, ofs, &oi) < 0) {
1880 struct object_id oid;
1881 nth_bitmap_object_oid(bitmap_git, &oid,
1882 pack_pos_to_index(pack, pos));
packfile.c
+4 -4
@@ -1580,7 +1580,7 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
1580 hashmap_add(&delta_base_cache, &ent->ent);
1581 }
1582
1583 -int packed_object_info(struct repository *r, struct packed_git *p,
1583 +int packed_object_info(struct packed_git *p,
1584 off_t obj_offset, struct object_info *oi)
1585 {
1586 struct pack_window *w_curs = NULL;
@@ -1594,7 +1594,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
1594 * a "real" type later if the caller is interested.
1595 */
1596 if (oi->contentp) {
1597 - *oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep,
1597 + *oi->contentp = cache_or_unpack_entry(p->repo, p, obj_offset, oi->sizep,
1598 &type);
1599 if (!*oi->contentp)
1600 type = OBJ_BAD;
@@ -1635,7 +1635,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
1635
1636 if (oi->typep) {
1637 enum object_type ptot;
1638 - ptot = packed_to_object_type(r, p, obj_offset,
1638 + ptot = packed_to_object_type(p->repo, p, obj_offset,
1639 type, &w_curs, curpos);
1640 if (oi->typep)
1641 *oi->typep = ptot;
@@ -2170,7 +2170,7 @@ int packfile_store_read_object_info(struct packfile_store *store,
2170 if (!oi)
2171 return 0;
2172
2173 - ret = packed_object_info(store->odb->repo, e.p, e.offset, oi);
2173 + ret = packed_object_info(e.p, e.offset, oi);
2174 if (ret < 0) {
2175 mark_bad_packed_object(e.p, oid);
2176 return -1;
packfile.h
+1 -2
@@ -382,8 +382,7 @@ extern int do_check_packed_object_crc;
382 * Look up the object info for a specific offset in the packfile.
383 * Returns zero on success, a negative error code otherwise.
384 */
385 -int packed_object_info(struct repository *r,
386 - struct packed_git *pack,
385 +int packed_object_info(struct packed_git *pack,
386 off_t offset, struct object_info *);
387
388 void mark_bad_packed_object(struct packed_git *, const struct object_id *);