lock_ref_sha1_basic(): if locking fails with ENOENT, retry