]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: drop unused `for_each_{loose,packed}_object()` functions
authorPatrick Steinhardt <ps@pks.im>
Thu, 15 Jan 2026 11:04:43 +0000 (12:04 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jan 2026 13:50:29 +0000 (05:50 -0800)
We have converted all callers of `for_each_loose_object()` and
`for_each_packed_object()` to use their new replacement functions
instead. We can thus remove them now.

Do so and inline `packfile_store_for_each_object_internal()` now that it
only has a single callsite again. This makes it a bit easier to follow
the callback indirection that is happening there.

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

index c0f896673b1d6d8eceae46af72ac58041963bb12..bc5209f2fe57c979af412eeac340c31567e80d77 100644 (file)
@@ -1802,26 +1802,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
        return r;
 }
 
-int for_each_loose_object(struct object_database *odb,
-                         each_loose_object_fn cb, void *data,
-                         enum odb_for_each_object_flags flags)
-{
-       struct odb_source *source;
-
-       odb_prepare_alternates(odb);
-       for (source = odb->sources; source; source = source->next) {
-               int r = for_each_loose_file_in_source(source, cb, NULL,
-                                                     NULL, data);
-               if (r)
-                       return r;
-
-               if (flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY)
-                       break;
-       }
-
-       return 0;
-}
-
 struct for_each_object_wrapper_data {
        struct odb_source *source;
        struct object_info *oi;
index 048b778531157ffc3deab7d6f47e8f12993765d7..af7f57d2a10a65402e1918b5c81862c523c0e8ec 100644 (file)
@@ -126,17 +126,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
                                  each_loose_subdir_fn subdir_cb,
                                  void *data);
 
-/*
- * Iterate over all accessible loose objects without respect to
- * reachability. By default, this includes both local and alternate objects.
- * The order in which objects are visited is unspecified.
- *
- * Any flags specific to packs are ignored.
- */
-int for_each_loose_object(struct object_database *odb,
-                         each_loose_object_fn, void *,
-                         enum odb_for_each_object_flags flags);
-
 /*
  * Iterate through all loose objects in the given object database source and
  * invoke the callback function for each of them. If given, the object info
index c96ec21f866e713b0a24f1971c6e21e01b6f2442..493d81fdcaa740d288c389a4a04d941c50a95072 100644 (file)
@@ -2326,65 +2326,6 @@ int for_each_object_in_pack(struct packed_git *p,
        return r;
 }
 
-static int packfile_store_for_each_object_internal(struct packfile_store *store,
-                                                  each_packed_object_fn cb,
-                                                  void *data,
-                                                  unsigned flags,
-                                                  int *pack_errors)
-{
-       struct packfile_list_entry *e;
-       int ret = 0;
-
-       store->skip_mru_updates = true;
-
-       for (e = packfile_store_get_packs(store); e; e = e->next) {
-               struct packed_git *p = e->pack;
-
-               if ((flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
-                       continue;
-               if ((flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY) &&
-                   !p->pack_promisor)
-                       continue;
-               if ((flags & ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
-                   p->pack_keep_in_core)
-                       continue;
-               if ((flags & ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
-                   p->pack_keep)
-                       continue;
-               if (open_pack_index(p)) {
-                       *pack_errors = 1;
-                       continue;
-               }
-
-               ret = for_each_object_in_pack(p, cb, data, flags);
-               if (ret)
-                       break;
-       }
-
-       store->skip_mru_updates = false;
-
-       return ret;
-}
-
-int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
-                          void *data, unsigned flags)
-{
-       struct odb_source *source;
-       int pack_errors = 0;
-       int ret = 0;
-
-       odb_prepare_alternates(repo->objects);
-
-       for (source = repo->objects->sources; source; source = source->next) {
-               ret = packfile_store_for_each_object_internal(source->packfiles, cb, data,
-                                                             flags, &pack_errors);
-               if (ret)
-                       break;
-       }
-
-       return ret ? ret : pack_errors;
-}
-
 struct packfile_store_for_each_object_wrapper_data {
        struct packfile_store *store;
        struct object_info *oi;
@@ -2424,12 +2365,37 @@ int packfile_store_for_each_object(struct packfile_store *store,
                .cb = cb,
                .cb_data = cb_data,
        };
+       struct packfile_list_entry *e;
        int pack_errors = 0, ret;
 
-       ret = packfile_store_for_each_object_internal(store, packfile_store_for_each_object_wrapper,
-                                                     &data, flags, &pack_errors);
-       if (ret)
-               return ret;
+       store->skip_mru_updates = true;
+
+       for (e = packfile_store_get_packs(store); e; e = e->next) {
+               struct packed_git *p = e->pack;
+
+               if ((flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
+                       continue;
+               if ((flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY) &&
+                   !p->pack_promisor)
+                       continue;
+               if ((flags & ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
+                   p->pack_keep_in_core)
+                       continue;
+               if ((flags & ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
+                   p->pack_keep)
+                       continue;
+               if (open_pack_index(p)) {
+                       pack_errors = 1;
+                       continue;
+               }
+
+               ret = for_each_object_in_pack(p, packfile_store_for_each_object_wrapper,
+                                             &data, flags);
+               if (ret)
+                       break;
+       }
+
+       store->skip_mru_updates = false;
 
        return pack_errors ? -1 : 0;
 }
index ab0637fbe9287b86005df7825f390da960637022..8e0d2b76616223e0bbf7c75818fefe7bdff0e00c 100644 (file)
@@ -340,8 +340,6 @@ typedef int each_packed_object_fn(const struct object_id *oid,
 int for_each_object_in_pack(struct packed_git *p,
                            each_packed_object_fn, void *data,
                            unsigned flags);
-int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
-                          void *data, unsigned flags);
 
 /*
  * Iterate through all packed objects in the given packfile store and invoke