aboutsummaryrefslogtreecommitdiff
path: root/odb/source.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-05 15:19:56 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-05 11:45:17 -0800
commiteb9635d83b7ef16df527db3e84def9d0c772344d (patch)
tree3f99a1d51f8ca693aab88600c544612239d92560 /odb/source.h
parent7ae23630c3ed012180edc88f0a9615a0d570a77c (diff)
downloadgit-eb9635d83b7ef16df527db3e84def9d0c772344d.tar.xz
odb/source: make `write_alternate()` function pluggable
Introduce a new callback function in `struct odb_source` to make the function pluggable. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'odb/source.h')
-rw-r--r--odb/source.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/odb/source.h b/odb/source.h
index fbdddcb2eb..ee540630d2 100644
--- a/odb/source.h
+++ b/odb/source.h
@@ -245,6 +245,19 @@ struct odb_source {
*/
int (*read_alternates)(struct odb_source *source,
struct strvec *out);
+
+ /*
+ * This callback is expected to persist the singular alternate passed
+ * to it into its list of alternates. Any pre-existing alternates are
+ * expected to remain active. Subsequent calls to `read_alternates` are
+ * thus expected to yield the pre-existing list of alternates plus the
+ * newly added alternate appended to its end.
+ *
+ * The callback is expected to return 0 on success, a negative error
+ * code otherwise.
+ */
+ int (*write_alternate)(struct odb_source *source,
+ const char *alternate);
};
/*
@@ -412,4 +425,17 @@ static inline int odb_source_read_alternates(struct odb_source *source,
return source->read_alternates(source, out);
}
+/*
+ * Write and persist a new alternate object database source for the given
+ * source. Any preexisting alternates are expected to stay valid, and the new
+ * alternate shall be appended to the end of the list.
+ *
+ * Returns 0 on success, a negative error code otherwise.
+ */
+static inline int odb_source_write_alternate(struct odb_source *source,
+ const char *alternate)
+{
+ return source->write_alternate(source, alternate);
+}
+
#endif