lock_ref_sha1_basic: handle REF_NODEREF with invalid refs