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>
This commit is contained in:
Patrick Steinhardt 2026-01-15 12:04:43 +01:00 committed by Junio C Hamano
parent 9a9a207cb3
commit e5901df2f3
4 changed files with 29 additions and 96 deletions

View 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;

View 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

View 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;
}

View 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