mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-28 18:55:47 -05:00
odb/transaction: propagate commit errors
When `odb_transaction_commit()` is invoked, the return value of the backend commit callback is silently discarded. A backend has no way to signal that committing failed, such as when the "files" backend cannot migrate its temporary object directory into the permanent ODB. In a subsequent commit, git-receive-pack(1) starts using ODB transaction to stage objects and consequently cares about such failures so it can handle the error appropriately. Change the commit callback signature to return an int error code and have `odb_transaction_commit()` forward it accordingly. 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
1bfc358fd8
commit
a72d74fa59
@@ -18,19 +18,26 @@ 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);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
transaction->source->odb->transaction = NULL;
|
||||
free(transaction);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int odb_transaction_write_object_stream(struct odb_transaction *transaction,
|
||||
|
||||
@@ -54,7 +54,7 @@ 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.
|
||||
*/
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user