Move the check for check_refname_format from lock_any_ref_for_update
to lock_ref_sha1_basic. At some later stage we will get rid of
lock_any_ref_for_update completely.

This leaves lock_any_ref_for_updates as a no-op wrapper which could be removed.
But this wrapper is also called from an external caller and we will soon
make changes to the signature to lock_ref_sha1_basic that we do not want to
expose to that caller.

Signed-off-by: Ronnie Sahlberg <>
 refs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/refs.c b/refs.c
index 79d95db..53fdbd1 100644
--- a/refs.c
+++ b/refs.c
@@ -2044,6 +2044,9 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
        int missing = 0;
        int attempts_remaining = 3;
+       if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
+               return NULL;
        lock = xcalloc(1, sizeof(struct ref_lock));
        lock->lock_fd = -1;
@@ -2135,8 +2138,6 @@ struct ref_lock *lock_any_ref_for_update(const char 
                                         const unsigned char *old_sha1,
                                         int flags, int *type_p)
-       if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
-               return NULL;
        return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to