aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-01-26 10:51:30 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-26 08:26:08 -0800
commit3565faf28c2059c6260d53ac71a303b1c04b0a7b (patch)
treee2340a2664b00248b9a119700318ca30ae50fff0
parent7a8582c82ce896d89bbcc1d91d8b5bdc31902416 (diff)
downloadgit-3565faf28c2059c6260d53ac71a303b1c04b0a7b.tar.xz
odb: drop unused `for_each_{loose,packed}_object()` functions
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>
-rw-r--r--object-file.c20
-rw-r--r--object-file.h11
-rw-r--r--packfile.c99
-rw-r--r--packfile.h2
4 files changed, 35 insertions, 97 deletions
diff --git a/object-file.c b/object-file.c
index 5537ab2c37..6785821c8c 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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;
const struct object_info *request;
diff --git a/object-file.h b/object-file.h
index b5eac0349e..d9979baea8 100644
--- a/object-file.h
+++ b/object-file.h
@@ -127,17 +127,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
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 an object info request is
* given, then the object info will be read for every individual object and
diff --git a/packfile.c b/packfile.c
index 845633139f..57fbf51876 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2327,65 +2327,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;
const struct object_info *request;
@@ -2428,14 +2369,44 @@ 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)
+ goto out;
+ }
+
+ ret = 0;
- return pack_errors ? -1 : 0;
+out:
+ store->skip_mru_updates = false;
+
+ if (!ret && pack_errors)
+ ret = -1;
+ return ret;
}
struct add_promisor_object_data {
diff --git a/packfile.h b/packfile.h
index b7964f0289..1a1b720764 100644
--- a/packfile.h
+++ b/packfile.h
@@ -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