aboutsummaryrefslogtreecommitdiff
path: root/odb.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-01-26 10:51:23 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-26 08:26:07 -0800
commitdf2fbdfa553526062e5234286f60bd643941298a (patch)
tree84c0145fb135bea7ff9a23dcddd35f5a05be9bd1 /odb.h
parent736464b84f4439361ec10e9ef49bff674fea952d (diff)
downloadgit-df2fbdfa553526062e5234286f60bd643941298a.tar.xz
odb: introduce `odb_for_each_object()`
Introduce a new function `odb_for_each_object()` that knows to iterate through all objects part of a given object database. This function is essentially a simple wrapper around the object database sources. Subsequent commits will adapt callers to use this new function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'odb.h')
-rw-r--r--odb.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/odb.h b/odb.h
index f97f249580..b5d28bc188 100644
--- a/odb.h
+++ b/odb.h
@@ -475,6 +475,26 @@ typedef int (*odb_for_each_object_cb)(const struct object_id *oid,
struct object_info *oi,
void *cb_data);
+/*
+ * Iterate through all objects contained in the object database. Note that
+ * objects may be iterated over multiple times in case they are either stored
+ * in different backends or in case they are stored in multiple sources.
+ * If an object info request is given, then the object info will be read and
+ * passed to the callback as if `odb_read_object_info()` was called for the
+ * object.
+ *
+ * Returning a non-zero error code from the callback function will cause
+ * iteration to abort. The error code will be propagated.
+ *
+ * Returns 0 on success, a negative error code in case a failure occurred, or
+ * an arbitrary non-zero error code returned by the callback itself.
+ */
+int odb_for_each_object(struct object_database *odb,
+ const struct object_info *request,
+ odb_for_each_object_cb cb,
+ void *cb_data,
+ unsigned flags);
+
enum {
/*
* By default, `odb_write_object()` does not actually write anything