]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: drop repository parameter from `packed_object_info()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 18 Dec 2025 10:54:19 +0000 (11:54 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Dec 2025 11:55:18 +0000 (20:55 +0900)
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>
builtin/cat-file.c
builtin/pack-objects.c
commit-graph.c
pack-bitmap.c
packfile.c
packfile.h

index 505ddaa12f530934ca1b910cd271dff2ab9227ee..2ad712e9f8f55ce4d2bc4b1f2d8b8cd1066c56de 100644 (file)
@@ -487,8 +487,7 @@ static void batch_object_write(const char *obj_name,
                        data->info.sizep = &data->size;
 
                if (pack)
-                       ret = packed_object_info(the_repository, pack,
-                                                offset, &data->info);
+                       ret = packed_object_info(pack, offset, &data->info);
                else
                        ret = odb_read_object_info_extended(the_repository->objects,
                                                            &data->oid, &data->info,
index 1ce8d6ee21532655366547bf87373a30be91f38a..85762f8c4fc4cc4b274d02ae4e7f5fa75709b4d5 100644 (file)
@@ -2411,7 +2411,7 @@ static void drop_reused_delta(struct object_entry *entry)
 
        oi.sizep = &size;
        oi.typep = &type;
-       if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
+       if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
                /*
                 * We failed to get the info from this pack for some reason;
                 * 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,
                struct object_info oi = OBJECT_INFO_INIT;
 
                oi.typep = &type;
-               if (packed_object_info(the_repository, p, ofs, &oi) < 0) {
+               if (packed_object_info(p, ofs, &oi) < 0) {
                        die(_("could not get type of object %s in pack %s"),
                            oid_to_hex(oid), p->pack_name);
                } else if (type == OBJ_COMMIT) {
index 80be2ff2c39842675c962d262021a993e6b00cc5..f572670bd01946c9f9a9e560eae650ea4f28f564 100644 (file)
@@ -1499,7 +1499,7 @@ static int add_packed_commits(const struct object_id *oid,
                display_progress(ctx->progress, ++ctx->progress_done);
 
        oi.typep = &type;
-       if (packed_object_info(ctx->r, pack, offset, &oi) < 0)
+       if (packed_object_info(pack, offset, &oi) < 0)
                die(_("unable to get type of object %s"), oid_to_hex(oid));
 
        if (type != OBJ_COMMIT)
index 8ca79725b1d4380377fc4c0e68141c7fc1968401..972203f12b6d9b9e18a08a5b7d81d284f162c567 100644 (file)
@@ -1876,8 +1876,7 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git,
                        ofs = pack_pos_to_offset(pack, pos);
                }
 
-               if (packed_object_info(bitmap_repo(bitmap_git), pack, ofs,
-                                      &oi) < 0) {
+               if (packed_object_info(pack, ofs, &oi) < 0) {
                        struct object_id oid;
                        nth_bitmap_object_oid(bitmap_git, &oid,
                                              pack_pos_to_index(pack, pos));
index a2ba237ce76f57f27e5b52f6df9679aa5c1823c3..39899aec494468f0a593ad67f14b60a897440b14 100644 (file)
@@ -1580,7 +1580,7 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
        hashmap_add(&delta_base_cache, &ent->ent);
 }
 
-int packed_object_info(struct repository *r, struct packed_git *p,
+int packed_object_info(struct packed_git *p,
                       off_t obj_offset, struct object_info *oi)
 {
        struct pack_window *w_curs = NULL;
@@ -1594,7 +1594,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
         * a "real" type later if the caller is interested.
         */
        if (oi->contentp) {
-               *oi->contentp = cache_or_unpack_entry(r, p, obj_offset, oi->sizep,
+               *oi->contentp = cache_or_unpack_entry(p->repo, p, obj_offset, oi->sizep,
                                                      &type);
                if (!*oi->contentp)
                        type = OBJ_BAD;
@@ -1635,7 +1635,7 @@ int packed_object_info(struct repository *r, struct packed_git *p,
 
        if (oi->typep) {
                enum object_type ptot;
-               ptot = packed_to_object_type(r, p, obj_offset,
+               ptot = packed_to_object_type(p->repo, p, obj_offset,
                                             type, &w_curs, curpos);
                if (oi->typep)
                        *oi->typep = ptot;
@@ -2170,7 +2170,7 @@ int packfile_store_read_object_info(struct packfile_store *store,
        if (!oi)
                return 0;
 
-       ret = packed_object_info(store->odb->repo, e.p, e.offset, oi);
+       ret = packed_object_info(e.p, e.offset, oi);
        if (ret < 0) {
                mark_bad_packed_object(e.p, oid);
                return -1;
index 07f5bfbc4fc63126fbfaa73417640de070043275..573d06f6ba35b0cb19fa6b1bd9333af1dae26e4a 100644 (file)
@@ -382,8 +382,7 @@ extern int do_check_packed_object_crc;
  * Look up the object info for a specific offset in the packfile.
  * success, a negative error code otherwise.
  */
-int packed_object_info(struct repository *r,
-                      struct packed_git *pack,
+int packed_object_info(struct packed_git *pack,
                       off_t offset, struct object_info *);
 
 void mark_bad_packed_object(struct packed_git *, const struct object_id *);