Since we now pass meaningful error messages back from ref_transaction_commit on failures, we no longer need to provide a onerr argument. The callers can now on commit failures die() with a meaningful, and in most cases even better than before, error message. Signed-off-by: Ronnie Sahlberg <sahlberg@xxxxxxxxxx> --- builtin/update-ref.c | 3 +-- refs.c | 22 +++++++--------------- refs.h | 3 +-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 47c9b53..df3cd92 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -368,8 +368,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) if (end_null) line_termination = '\0'; update_refs_stdin(); - if (ref_transaction_commit(transaction, msg, &err, - UPDATE_REFS_QUIET_ON_ERR)) + if (ref_transaction_commit(transaction, msg, &err)) die("update_ref failed: %s", err); return 0; } diff --git a/refs.c b/refs.c index 7562151..0e2df81 100644 --- a/refs.c +++ b/refs.c @@ -3397,8 +3397,7 @@ static int ref_update_compare(const void *r1, const void *r2) } static int ref_update_reject_duplicates(struct ref_update **updates, int n, - char **err, - enum action_on_err onerr) + char **err) { int i; for (i = 1; i < n; i++) @@ -3410,22 +3409,13 @@ static int ref_update_reject_duplicates(struct ref_update **updates, int n, snprintf(*err, PATH_MAX + 41, str, updates[i]->refname); } - switch (onerr) { - case UPDATE_REFS_MSG_ON_ERR: - error(str, updates[i]->refname); break; - case UPDATE_REFS_DIE_ON_ERR: - die(str, updates[i]->refname); break; - case UPDATE_REFS_QUIET_ON_ERR: - break; - } return 1; } return 0; } int ref_transaction_commit(struct ref_transaction *transaction, - const char *msg, char **err, - enum action_on_err onerr) + const char *msg, char **err) { int ret = 0, delnum = 0, i; const char **delnames; @@ -3443,7 +3433,7 @@ int ref_transaction_commit(struct ref_transaction *transaction, /* Copy, sort, and reject duplicate refs */ qsort(updates, n, sizeof(*updates), ref_update_compare); - ret = ref_update_reject_duplicates(updates, n, err, onerr); + ret = ref_update_reject_duplicates(updates, n, err); if (ret) goto cleanup; @@ -3455,7 +3445,8 @@ int ref_transaction_commit(struct ref_transaction *transaction, (update->have_old ? update->old_sha1 : NULL), update->flags, - &update->type, onerr); + &update->type, + UPDATE_REFS_QUIET_ON_ERR); if (!update->lock) { if (err) { const char *str = "Cannot lock the ref '%s'."; @@ -3476,7 +3467,8 @@ int ref_transaction_commit(struct ref_transaction *transaction, ret = update_ref_write(msg, update->refname, update->new_sha1, - update->lock, err, onerr); + update->lock, err, + UPDATE_REFS_QUIET_ON_ERR); update->lock = NULL; /* freed by update_ref_write */ if (ret) goto cleanup; diff --git a/refs.h b/refs.h index 615c73d..f3db632 100644 --- a/refs.h +++ b/refs.h @@ -272,8 +272,7 @@ void ref_transaction_delete(struct ref_transaction *transaction, * why a commit failed. This string must be free()ed by the caller. */ int ref_transaction_commit(struct ref_transaction *transaction, - const char *msg, char **err, - enum action_on_err onerr); + const char *msg, char **err); /** Lock a ref and then write its file */ int update_ref(const char *action, const char *refname, -- 1.9.1.521.g5dc89fa -- 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