From fa7d067923a342c298b7723935c60217a5244e4e Mon Sep 17 00:00:00 2001 From: Justin Tobler Date: Mon, 2 Feb 2026 18:10:01 -0600 Subject: odb: prepare `struct odb_transaction` to become generic An ODB transaction handles how objects are stored temporarily and eventually committed. Due to object storage being implemented differently for a given ODB source, the ODB transactions must be implemented in a manner specific to the source the objects are being written to. To provide generic transactions, `struct odb_transaction` is updated to store a commit callback that can be configured to support a specific ODB source. For now `struct odb_transaction_files` is the only transaction type and what is always returned when starting a transaction. Signed-off-by: Justin Tobler Signed-off-by: Junio C Hamano --- odb.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'odb.h') diff --git a/odb.h b/odb.h index bab07755f4..83d3a37805 100644 --- a/odb.h +++ b/odb.h @@ -77,7 +77,24 @@ struct odb_source { struct packed_git; struct packfile_store; struct cached_object_entry; + +/* + * A transaction may be started for an object database prior to writing new + * objects via odb_transaction_begin(). These objects are not committed until + * odb_transaction_commit() is invoked. Only a single transaction may be pending + * at a time. + * + * Each ODB source is expected to implement its own transaction handling. + */ struct odb_transaction; +typedef void (*odb_transaction_commit_fn)(struct odb_transaction *transaction); +struct odb_transaction { + /* The ODB source the transaction is opened against. */ + struct odb_source *source; + + /* The ODB source specific callback invoked to commit a transaction. */ + odb_transaction_commit_fn commit; +}; /* * The object database encapsulates access to objects in a repository. It -- cgit v1.3