Subject: Re: [PATCH 06/20] refs/files: remove "name exist?" check in lock_ref_oid_basic()

From: Junio C Hamano <[email-masked]>
Date: Thu, 14 Oct 2021 13:53:13 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 0af6ee44552..0dd21b2e205 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -1013,16 +1013,6 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
>  	CALLOC_ARRAY(lock, 1);
>  
>  	files_ref_path(refs, &ref_file, refname);
> -	if (!refs_resolve_ref_unsafe(&refs->base, refname,
> -				     RESOLVE_REF_NO_RECURSE,
> -				     &lock->old_oid, type)) {
> -		if (!refs_verify_refname_available(&refs->base, refname,
> -						   NULL, NULL, err))
> -			strbuf_addf(err, "unable to resolve reference '%s': %s",
> -				    refname, strerror(errno));
> -
> -		goto error_return;
> -	}
>  
>  	/*
>  	 * If the ref did not exist and we are creating it, make sure

This has the side effect of "type" not touched at all by this
function, which in turn triggers "type is used uninitialized?"
error in files_reflog_expire() that calls this function.