Subject: Re: [PATCH 4/4] tag: "git tag" refuses to use HEAD as a tagname

From: Junio C Hamano <[email-masked]>
Date: Tue, 03 Dec 2024 10:35:01 +0900

Rubén Justo <[email-masked]> writes:

> --- a/t/t7004-tag.sh
> +++ b/t/t7004-tag.sh
> @@ -97,6 +97,11 @@ test_expect_success 'HEAD is forbidden as a tagname' '
>  	test_must_fail git tag -a -m "useless" HEAD
>  '
>  
> +test_expect_success 'allow deleting a tag named HEAD' '
> +	git update-ref refs/tags/HEAD HEAD &&
> +	git tag -d HEAD
> +'

This concisely captures exactly what we want to see.  The plumbing
is still allowed to create something that the worldview given by the
Git Porcelain UI may not like (so that people can create different UI)
and our tool can still be usable to recover from a mistake of using
HEAD as the name of a tag, which we more strongly discourage.

Good idea.

>> +test_expect_success 'HEAD is forbidden as a tagname' '
>> +	test_when_finished "git tag -d HEAD || :" &&
>
> I'm not considering this as a test for it :-)

It is not.  If "git tag HEAD" get broken in the future, the
must-fail steps below may create such a tag, and we want to remove
it before moving along.