]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: use higher-level interface to implement `has_object_pack()`
authorPatrick Steinhardt <ps@pks.im>
Wed, 17 Jun 2026 06:39:51 +0000 (08:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Jun 2026 12:00:00 +0000 (05:00 -0700)
In `has_object_pack()` we're checking whether a specific object exists
as part of a packfile. This is done by calling the low-level function
`find_pack_entry()`, but this function will eventually be moved into
"odb/source-packed.c" and made file-local.

Refactor the code to use `packfile_store_read_object_info()` instead.
This refactoring is functionally equivalent as that function will call
`find_pack_entry()` itself and then return immediately when it ain't got
no object info pointer as parameter.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
packfile.c

index 65631f674f1e1cb179d94dc0bc98d7dc73ef5eb0..b35afd77979fc9773ec891105612734b61f003a0 100644 (file)
@@ -2049,14 +2049,12 @@ struct packed_git **packfile_store_get_kept_pack_cache(struct odb_source_packed
 int has_object_pack(struct repository *r, const struct object_id *oid)
 {
        struct odb_source *source;
-       struct pack_entry e;
 
        odb_prepare_alternates(r->objects);
        for (source = r->objects->sources; source; source = source->next) {
                struct odb_source_files *files = odb_source_files_downcast(source);
-               int ret = find_pack_entry(files->packed, oid, &e);
-               if (ret)
-                       return ret;
+               if (!packfile_store_read_object_info(files->packed, oid, NULL, 0))
+                       return 1;
        }
 
        return 0;