Skip to content

Commit 3565faf

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 7a8582c commit 3565faf

4 files changed

Lines changed: 35 additions & 97 deletions

File tree

object-file.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,26 +1802,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
18021802
return r;
18031803
}
18041804

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-
18251805
struct for_each_object_wrapper_data {
18261806
struct odb_source *source;
18271807
const struct object_info *request;

object-file.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,6 @@ int for_each_loose_file_in_source(struct odb_source *source,
126126
each_loose_subdir_fn subdir_cb,
127127
void *data);
128128

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-
140129
/*
141130
* Iterate through all loose objects in the given object database source and
142131
* invoke the callback function for each of them. If an object info request is

packfile.c

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,65 +2327,6 @@ int for_each_object_in_pack(struct packed_git *p,
23272327
return r;
23282328
}
23292329

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-
23892330
struct packfile_store_for_each_object_wrapper_data {
23902331
struct packfile_store *store;
23912332
const struct object_info *request;
@@ -2428,14 +2369,44 @@ int packfile_store_for_each_object(struct packfile_store *store,
24282369
.cb = cb,
24292370
.cb_data = cb_data,
24302371
};
2372+
struct packfile_list_entry *e;
24312373
int pack_errors = 0, ret;
24322374

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

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;
24392410
}
24402411

24412412
struct add_promisor_object_data {

packfile.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ typedef int each_packed_object_fn(const struct object_id *oid,
340340
int for_each_object_in_pack(struct packed_git *p,
341341
each_packed_object_fn, void *data,
342342
unsigned flags);
343-
int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
344-
void *data, unsigned flags);
345343

346344
/*
347345
* Iterate through all packed objects in the given packfile store and invoke

0 commit comments

Comments
 (0)