Skip to content

Commit 45421e2

Browse files
rsahlberggitster
authored andcommitted
refs.c: remove the update_ref_lock function
Since we now only call update_ref_lock with onerr==QUIET_ON_ERR we no longer need this function and can replace it with just calling lock_any_ref_for_update directly. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 88b680a commit 45421e2

1 file changed

Lines changed: 6 additions & 24 deletions

File tree

refs.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,24 +3336,6 @@ int for_each_reflog(each_ref_fn fn, void *cb_data)
33363336
return retval;
33373337
}
33383338

3339-
static struct ref_lock *update_ref_lock(const char *refname,
3340-
const unsigned char *oldval,
3341-
int flags, int *type_p,
3342-
enum action_on_err onerr)
3343-
{
3344-
struct ref_lock *lock;
3345-
lock = lock_any_ref_for_update(refname, oldval, flags, type_p);
3346-
if (!lock) {
3347-
const char *str = "Cannot lock the ref '%s'.";
3348-
switch (onerr) {
3349-
case UPDATE_REFS_MSG_ON_ERR: error(str, refname); break;
3350-
case UPDATE_REFS_DIE_ON_ERR: die(str, refname); break;
3351-
case UPDATE_REFS_QUIET_ON_ERR: break;
3352-
}
3353-
}
3354-
return lock;
3355-
}
3356-
33573339
static int update_ref_write(const char *action, const char *refname,
33583340
const unsigned char *sha1, struct ref_lock *lock,
33593341
struct strbuf *err, enum action_on_err onerr)
@@ -3603,12 +3585,12 @@ int ref_transaction_commit(struct ref_transaction *transaction,
36033585
for (i = 0; i < n; i++) {
36043586
struct ref_update *update = updates[i];
36053587

3606-
update->lock = update_ref_lock(update->refname,
3607-
(update->have_old ?
3608-
update->old_sha1 : NULL),
3609-
update->flags,
3610-
&update->type,
3611-
UPDATE_REFS_QUIET_ON_ERR);
3588+
update->lock = lock_any_ref_for_update(update->refname,
3589+
(update->have_old ?
3590+
update->old_sha1 :
3591+
NULL),
3592+
update->flags,
3593+
&update->type);
36123594
if (!update->lock) {
36133595
if (err)
36143596
strbuf_addf(err, "Cannot lock the ref '%s'.",

0 commit comments

Comments
 (0)