diff --git a/odb/transaction.c b/odb/transaction.c index b6da4a3942..249ef4d9b7 100644 --- a/odb/transaction.c +++ b/odb/transaction.c @@ -18,19 +18,23 @@ int odb_transaction_begin(struct object_database *odb, return ret; } -void odb_transaction_commit(struct odb_transaction *transaction) +int odb_transaction_commit(struct odb_transaction *transaction) { + int ret; + if (!transaction) - return; + return 0; /* * Ensure the transaction ending matches the pending transaction. */ ASSERT(transaction == transaction->source->odb->transaction); - transaction->commit(transaction); + ret = transaction->commit(transaction); transaction->source->odb->transaction = NULL; free(transaction); + + return ret; } int odb_transaction_write_object_stream(struct odb_transaction *transaction, diff --git a/odb/transaction.h b/odb/transaction.h index f5c43187c9..3b0a5a78e5 100644 --- a/odb/transaction.h +++ b/odb/transaction.h @@ -54,10 +54,11 @@ static inline void odb_transaction_begin_or_die(struct object_database *odb, } /* - * Commits an ODB transaction making the written objects visible. If the - * specified transaction is NULL, the function is a no-op. + * Commits an ODB transaction making the written objects visible. Returns 0 on + * success, a negative error code otherwise. Note that, if the specified + * transaction is NULL, the function is a no-op and no error is returned. */ -void odb_transaction_commit(struct odb_transaction *transaction); +int odb_transaction_commit(struct odb_transaction *transaction); /* * Writes the object in the provided stream into the transaction. The resulting