From: Patrick Steinhardt Date: Wed, 21 Jan 2026 12:50:16 GMT Subject: [PATCH v3 00/14] odb: introduce `odb_for_each_object()` Message-ID: <20260121-pks-odb-for-each-object-v3-0-12c4dfd24227@pks.im> In-Reply-To: <20260115-pks-odb-for-each-object-v1-0-5418a91d5d99@pks.im> Hi, this patch series introduces a generic `odb_for_each_object()` function to iterate through objects and adapts callers to use it. The intent is to make iteration through objects independent of the actual storage backend. The series is structured as follows: - Commits 1 to 2 do some cleanups for the for-each-object flags. - Commits 3 to 7 introduce the infrastructure for `odb_for_each_object()`. - Commits 8 to 13 convert a couple of callers to use the new interfaces. - Commit 14 drops now-unused functions. The patch series is built on top of 8745eae506 (The 17th batch, 2026-01-11) with the following two series merged into it: - ps/read-object-info-improvements at a282a8f163 (packfile: move MIDX into packfile store, 2026-01-09). - ps/packfile-store-in-odb-source at 12d3b58b55 (packfile: drop repository parameter from `packed_object_info()`, 2026-01-12) . Changes in v3: - Fix error code propagation in last commit. - Link to v2: https://lore.kernel.org/r/20260120-pks-odb-for-each-object-v2-0-d05cbfd3d6f8@pks.im Changes in v2: - Clarify the comment of `odb_for_each_object()` to point out that it's the callback that can abort iteration by returning a non-zero error code. - Document in the commit message that we don't yet convert all sites to use `odb_for_each_object()`. - Link to v1: https://lore.kernel.org/r/20260115-pks-odb-for-each-object-v1-0-5418a91d5d99@pks.im Thanks! Patrick --- Patrick Steinhardt (14): odb: rename `FOR_EACH_OBJECT_*` flags odb: fix flags parameter to be unsigned object-file: extract function to read object info from path object-file: introduce function to iterate through objects packfile: extract function to iterate through objects of a store packfile: introduce function to iterate through objects odb: introduce `odb_for_each_object()` builtin/fsck: refactor to use `odb_for_each_object()` treewide: enumerate promisor objects via `odb_for_each_object()` treewide: drop uses of `for_each_{loose,packed}_object()` odb: introduce mtime fields for object info requests builtin/pack-objects: use `packfile_store_for_each_object()` reachable: convert to use `odb_for_each_object()` odb: drop unused `for_each_{loose,packed}_object()` functions builtin/cat-file.c | 30 +++++++-- builtin/fsck.c | 57 ++++------------ builtin/pack-objects.c | 47 ++++++------- commit-graph.c | 46 +++++++++---- object-file.c | 120 +++++++++++++++++++++------------ object-file.h | 21 +++--- odb.c | 29 ++++++++ odb.h | 43 ++++++++++-- packfile.c | 180 +++++++++++++++++++++++++++++++++---------------- packfile.h | 18 ++++- reachable.c | 129 ++++++++++------------------------- repack-promisor.c | 8 +-- revision.c | 10 ++- 13 files changed, 426 insertions(+), 312 deletions(-) Range-diff versus v2: 1: 3cd6a9b898 = 1: f931af359e odb: rename `FOR_EACH_OBJECT_*` flags 2: 2b9a766928 = 2: 4454d3b8e6 odb: fix flags parameter to be unsigned 3: e5a8257291 = 3: 0953291ffc object-file: extract function to read object info from path 4: 309fb50d2a = 4: b0a8ff2d9d object-file: introduce function to iterate through objects 5: 8332af532d = 5: def018bbca packfile: extract function to iterate through objects of a store 6: 17675561dc = 6: caccd45aa0 packfile: introduce function to iterate through objects 7: aa79e2f2ea = 7: 4e429e52b2 odb: introduce `odb_for_each_object()` 8: 33737e286b = 8: 8f16adec2c builtin/fsck: refactor to use `odb_for_each_object()` 9: 606b944a67 = 9: a1c95ffc4f treewide: enumerate promisor objects via `odb_for_each_object()` 10: bf31434259 = 10: c0ecc5517e treewide: drop uses of `for_each_{loose,packed}_object()` 11: 359ac505ae = 11: 1687ac9f3c odb: introduce mtime fields for object info requests 12: eb7c6f5571 = 12: 1d4b35e3a5 builtin/pack-objects: use `packfile_store_for_each_object()` 13: 80227f4d71 = 13: f360ff980a reachable: convert to use `odb_for_each_object()` 14: b614e33feb ! 14: bbad8b1a2b odb: drop unused `for_each_{loose,packed}_object()` functions @@ packfile.c: int packfile_store_for_each_object(struct packfile_store *store, + ret = for_each_object_in_pack(p, packfile_store_for_each_object_wrapper, + &data, flags); + if (ret) -+ break; ++ goto out; + } + -+ store->skip_mru_updates = false; ++ ret = 0; - return pack_errors ? -1 : 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 { ## packfile.h ## @@ packfile.h: typedef int each_packed_object_fn(const struct object_id *oid, --- base-commit: 1ff0e42d332523a11cc3d61b8d8463db5f9f14e8 change-id: 20260115-pks-odb-for-each-object-60b78cde09fd