diff options
| author | Justin Tobler <jltobler@gmail.com> | 2025-09-16 13:29:38 -0500 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-09-16 11:37:06 -0700 |
| commit | ce1661f9da70ea2ffcb54f7b544410fad26e965d (patch) | |
| tree | 3c6c03b10aa74bdece59ddae976af6550bca1ee0 /object-file.c | |
| parent | object-file: update naming from bulk-checkin (diff) | |
| download | git-ce1661f9da70ea2ffcb54f7b544410fad26e965d.tar.gz git-ce1661f9da70ea2ffcb54f7b544410fad26e965d.zip | |
odb: add transaction interface
Transactions are managed via the {begin,end}_odb_transaction() function
in the object-file subsystem and its implementation is specific to the
files object source. Introduce odb_transaction_{begin,commit}() in the
odb subsystem to provide an eventual object source agnostic means to
manage transactions.
Update call sites to instead manage transactions through the odb
subsystem. Also rename {begin,end}_odb_transaction() functions to
object_file_transaction_{begin,commit}() to clarify the object source it
supports.
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
| -rw-r--r-- | object-file.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/object-file.c b/object-file.c index 8103a2bf41..17a236d2fe 100644 --- a/object-file.c +++ b/object-file.c @@ -691,7 +691,7 @@ static void prepare_loose_object_transaction(struct odb_transaction *transaction * We lazily create the temporary object directory * the first time an object might be added, since * callers may not know whether any objects will be - * added at the time they call begin_odb_transaction. + * added at the time they call object_file_transaction_begin. */ if (!transaction || transaction->objdir) return; @@ -1622,12 +1622,12 @@ int index_fd(struct index_state *istate, struct object_id *oid, } else { struct odb_transaction *transaction; - transaction = begin_odb_transaction(the_repository->objects); + transaction = odb_transaction_begin(the_repository->objects); ret = index_blob_packfile_transaction(the_repository->objects->transaction, oid, fd, xsize_t(st->st_size), path, flags); - end_odb_transaction(transaction); + odb_transaction_commit(transaction); } close(fd); @@ -1967,8 +1967,10 @@ out: return ret; } -struct odb_transaction *begin_odb_transaction(struct object_database *odb) +struct odb_transaction *object_file_transaction_begin(struct odb_source *source) { + struct object_database *odb = source->odb; + if (odb->transaction) return NULL; @@ -1978,7 +1980,7 @@ struct odb_transaction *begin_odb_transaction(struct object_database *odb) return odb->transaction; } -void end_odb_transaction(struct odb_transaction *transaction) +void object_file_transaction_commit(struct odb_transaction *transaction) { if (!transaction) return; |
