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>
Patrick Steinhardt committed
Jan 26, 2026 at 10:51 UTC
3565faf28c2059c6260d53ac71a303b1c04b0a7b
4 files changed
+35
-97
object-file.c
-20
@@ -1802,26 +1802,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
1802
return r;
1803
}
1804
1805
-int for_each_loose_object(struct object_database *odb,
1806
- each_loose_object_fn cb, void *data,
1807
- enum odb_for_each_object_flags flags)
1808
-{
1809
- struct odb_source *source;
1810
-
1811
- odb_prepare_alternates(odb);
1812
- for (source = odb->sources; source; source = source->next) {
1813
- int r = for_each_loose_file_in_source(source, cb, NULL,
1814
- NULL, data);
1815
- if (r)
1816
- return r;
1817
-
1818
- if (flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY)
1819
- break;
1820
- }
1821
-
1822
- return 0;
1823
-}
1824
-
1805
struct for_each_object_wrapper_data {
1806
struct odb_source *source;
1807
const struct object_info *request;
object-file.h
-11
@@ -126,17 +126,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
126
each_loose_subdir_fn subdir_cb,
127
void *data);
128
129
-/*
130
- * Iterate over all accessible loose objects without respect to
131
- * reachability. By default, this includes both local and alternate objects.
132
- * The order in which objects are visited is unspecified.
133
- *
134
- * Any flags specific to packs are ignored.
135
- */
136
-int for_each_loose_object(struct object_database *odb,
137
- each_loose_object_fn, void *,
138
- enum odb_for_each_object_flags flags);
139
-
129
/*
130
* Iterate through all loose objects in the given object database source and
131
* invoke the callback function for each of them. If an object info request is
packfile.c
+35
-64
@@ -2327,65 +2327,6 @@ int for_each_object_in_pack(struct packed_git *p,
2327
return r;
2328
}
2329
2330
-static int packfile_store_for_each_object_internal(struct packfile_store *store,
2331
- each_packed_object_fn cb,
2332
- void *data,
2333
- unsigned flags,
2334
- int *pack_errors)
2335
-{
2336
- struct packfile_list_entry *e;
2337
- int ret = 0;
2338
-
2339
- store->skip_mru_updates = true;
2340
-
2341
- for (e = packfile_store_get_packs(store); e; e = e->next) {
2342
- struct packed_git *p = e->pack;
2343
-
2344
- if ((flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
2345
- continue;
2346
- if ((flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY) &&
2347
- !p->pack_promisor)
2348
- continue;
2349
- if ((flags & ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
2350
- p->pack_keep_in_core)
2351
- continue;
2352
- if ((flags & ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
2353
- p->pack_keep)
2354
- continue;
2355
- if (open_pack_index(p)) {
2356
- *pack_errors = 1;
2357
- continue;
2358
- }
2359
-
2360
- ret = for_each_object_in_pack(p, cb, data, flags);
2361
- if (ret)
2362
- break;
2363
- }
2364
-
2365
- store->skip_mru_updates = false;
2366
-
2367
- return ret;
2368
-}
2369
-
2370
-int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
2371
- void *data, unsigned flags)
2372
-{
2373
- struct odb_source *source;
2374
- int pack_errors = 0;
2375
- int ret = 0;
2376
-
2377
- odb_prepare_alternates(repo->objects);
2378
-
2379
- for (source = repo->objects->sources; source; source = source->next) {
2380
- ret = packfile_store_for_each_object_internal(source->packfiles, cb, data,
2381
- flags, &pack_errors);
2382
- if (ret)
2383
- break;
2384
- }
2385
-
2386
- return ret ? ret : pack_errors;
2387
-}
2388
-
2330
struct packfile_store_for_each_object_wrapper_data {
2331
struct packfile_store *store;
2332
const struct object_info *request;
@@ -2428,14 +2369,44 @@ int packfile_store_for_each_object(struct packfile_store *store,
2369
.cb = cb,
2370
.cb_data = cb_data,
2371
};
2372
+ struct packfile_list_entry *e;
2373
int pack_errors = 0, ret;
2374
2433
- ret = packfile_store_for_each_object_internal(store, packfile_store_for_each_object_wrapper,
2434
- &data, flags, &pack_errors);
2435
- if (ret)
2436
- return ret;
2375
+ store->skip_mru_updates = true;
2376
+
2377
+ for (e = packfile_store_get_packs(store); e; e = e->next) {
2378
+ struct packed_git *p = e->pack;
2379
+
2380
+ if ((flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
2381
+ continue;
2382
+ if ((flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY) &&
2383
+ !p->pack_promisor)
2384
+ continue;
2385
+ if ((flags & ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
2386
+ p->pack_keep_in_core)
2387
+ continue;
2388
+ if ((flags & ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
2389
+ p->pack_keep)
2390
+ continue;
2391
+ if (open_pack_index(p)) {
2392
+ pack_errors = 1;
2393
+ continue;
2394
+ }
2395
+
2396
+ ret = for_each_object_in_pack(p, packfile_store_for_each_object_wrapper,
2397
+ &data, flags);
2398
+ if (ret)
2399
+ goto out;
2400
+ }
2401
+
2402
+ ret = 0;
2403
2438
- return pack_errors ? -1 : 0;
2404
+out:
2405
+ store->skip_mru_updates = false;
2406
+
2407
+ if (!ret && pack_errors)
2408
+ ret = -1;
2409
+ return ret;
2410
}
2411
2412
struct add_promisor_object_data {
packfile.h
-2
@@ -340,8 +340,6 @@ typedef int each_packed_object_fn(const struct object_id *oid,
340
int for_each_object_in_pack(struct packed_git *p,
341
each_packed_object_fn, void *data,
342
unsigned flags);
343
-int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
344
- void *data, unsigned flags);
343
344
/*
345
* Iterate through all packed objects in the given packfile store and invoke