diff options
| author | Patrick Steinhardt <ps@pks.im> | 2026-01-26 10:51:22 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-01-26 08:26:07 -0800 |
| commit | 736464b84f4439361ec10e9ef49bff674fea952d (patch) | |
| tree | 362fb7eb8b1bca5761da4309f87717a46410d4f9 /packfile.h | |
| parent | 37353119046414b2dccb26b32cb5224e0c9258e1 (diff) | |
| download | git-736464b84f4439361ec10e9ef49bff674fea952d.tar.xz | |
packfile: introduce function to iterate through objects
Introduce a new function `packfile_store_for_each_object()`. This
function is equivalent to `odb_source_loose_for_each_object()`, except
that it:
- Works on a single packfile store instead of working on the object
database level. Consequently, it will only yield packed objects of a
single object database source.
- Passes a `struct object_info` to the callback function.
As such, it provides the same callback interface as we already provide
for loose objects now. These functions will be used in a subsequent step
to implement `odb_for_each_object()`.
The `for_each_packed_object()` function continues to exist for now, but
it will be removed at the end of this patch series.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.h')
| -rw-r--r-- | packfile.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packfile.h b/packfile.h index 447c44c4a7..b7964f0289 100644 --- a/packfile.h +++ b/packfile.h @@ -343,6 +343,21 @@ int for_each_object_in_pack(struct packed_git *p, 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 + * 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 passed to + * the callback as if `packfile_store_read_object_info()` was called for the + * object. + * + * The flags parameter is a combination of `odb_for_each_object_flags`. + */ +int packfile_store_for_each_object(struct packfile_store *store, + const struct object_info *request, + odb_for_each_object_cb cb, + void *cb_data, + unsigned flags); + /* A hook to report invalid files in pack directory */ #define PACKDIR_FILE_PACK 1 #define PACKDIR_FILE_IDX 2 |
