refs.c: remove the onerr argument to ref_transaction_commit
Since all callers now use QUIET_ON_ERR we no longer need to provide an onerr argument any more. Remove the onerr argument from the ref_transaction_commit signature. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
Ronnie Sahlberg committed
Jun 20, 2014 at 07:42 UTC
01319837c53050109c60e6740dfa9462327161f0
3 files changed
+9
-19
builtin/update-ref.c
+1
-2
@@ -366,8 +366,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
366
if (end_null)
367
line_termination = '\0';
368
update_refs_stdin();
369
- if (ref_transaction_commit(transaction, msg, &err,
370
- UPDATE_REFS_QUIET_ON_ERR))
369
+ if (ref_transaction_commit(transaction, msg, &err))
370
die("%s", err.buf);
371
ref_transaction_free(transaction);
372
return 0;
refs.c
+7
-15
@@ -3491,8 +3491,7 @@ static int ref_update_compare(const void *r1, const void *r2)
3491
}
3492
3493
static int ref_update_reject_duplicates(struct ref_update **updates, int n,
3494
- struct strbuf *err,
3495
- enum action_on_err onerr)
3494
+ struct strbuf *err)
3495
{
3496
int i;
3497
for (i = 1; i < n; i++)
@@ -3502,22 +3501,13 @@ static int ref_update_reject_duplicates(struct ref_update **updates, int n,
3501
if (err)
3502
strbuf_addf(err, str, updates[i]->refname);
3503
3505
- switch (onerr) {
3506
- case UPDATE_REFS_MSG_ON_ERR:
3507
- error(str, updates[i]->refname); break;
3508
- case UPDATE_REFS_DIE_ON_ERR:
3509
- die(str, updates[i]->refname); break;
3510
- case UPDATE_REFS_QUIET_ON_ERR:
3511
- break;
3512
- }
3504
return 1;
3505
}
3506
return 0;
3507
}
3508
3509
int ref_transaction_commit(struct ref_transaction *transaction,
3519
- const char *msg, struct strbuf *err,
3520
- enum action_on_err onerr)
3510
+ const char *msg, struct strbuf *err)
3511
{
3512
int ret = 0, delnum = 0, i;
3513
const char **delnames;
@@ -3532,7 +3522,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3522
3523
/* Copy, sort, and reject duplicate refs */
3524
qsort(updates, n, sizeof(*updates), ref_update_compare);
3535
- ret = ref_update_reject_duplicates(updates, n, err, onerr);
3525
+ ret = ref_update_reject_duplicates(updates, n, err);
3526
if (ret)
3527
goto cleanup;
3528
@@ -3544,7 +3534,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3534
(update->have_old ?
3535
update->old_sha1 : NULL),
3536
update->flags,
3547
- &update->type, onerr);
3537
+ &update->type,
3538
+ UPDATE_REFS_QUIET_ON_ERR);
3539
if (!update->lock) {
3540
if (err)
3541
strbuf_addf(err, "Cannot lock the ref '%s'.",
@@ -3562,7 +3553,8 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3553
ret = update_ref_write(msg,
3554
update->refname,
3555
update->new_sha1,
3565
- update->lock, err, onerr);
3556
+ update->lock, err,
3557
+ UPDATE_REFS_QUIET_ON_ERR);
3558
update->lock = NULL; /* freed by update_ref_write */
3559
if (ret)
3560
goto cleanup;
refs.h
+1
-2
@@ -282,8 +282,7 @@ void ref_transaction_delete(struct ref_transaction *transaction,
282
* the transaction failed. The string does not end in newline.
283
*/
284
int ref_transaction_commit(struct ref_transaction *transaction,
285
- const char *msg, struct strbuf *err,
286
- enum action_on_err onerr);
285
+ const char *msg, struct strbuf *err);
286
287
/*
288
* Free an existing transaction and all associated data.