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>
This commit is contained in:
committed by
Junio C Hamano
parent
ed0f5f93e9
commit
ce1661f9da
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user