Update ref_transaction_commit to have a single exit path and process onerr if an error occured during hte commit. This does mean that in case of an error occuring for UPDATE_REFS_MSG_ON_ERR during the calls to update_ref_lock or update_ref_write we will log errors from both those functions as well as a generic message from ref_transaction_commit. I thought a while to make the MSG_ON_ERR message in ref_transaction_commit conditional to only trigger if the error was not triggered by the two functions we call that also take onerr, and which would already have logger an error already for this case, but the code would just look too awful. I think it is acceptable to log two error messages for those two cases than to badify the commit code. Signed-off-by: Ronnie Sahlberg <sahlberg@xxxxxxxxxx> --- refs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index 138ab70..9daf89e 100644 --- a/refs.c +++ b/refs.c @@ -3414,12 +3414,12 @@ int ref_transaction_commit(struct ref_transaction *transaction, const char *msg, enum action_on_err onerr) { int ret = 0, delnum = 0, i; - const char **delnames; + const char **delnames = NULL; int n = transaction->nr; struct ref_update **updates = transaction->updates; if (!n) - return 0; + goto cleanup; /* Allocate work space */ delnames = xmalloc(sizeof(*delnames) * n); @@ -3481,6 +3481,14 @@ cleanup: unlock_ref(updates[i]->lock); free(delnames); ref_transaction_free(transaction); + if (ret) { + const char *str = "Cannot commit transaction."; + switch (onerr) { + case UPDATE_REFS_MSG_ON_ERR: error(str); break; + case UPDATE_REFS_DIE_ON_ERR: die(str); break; + case UPDATE_REFS_QUIET_ON_ERR: break; + } + } return ret; } -- 1.9.1.515.g3b87021 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html