]> git.ipfire.org Git - thirdparty/git.git/commit
tag: "git tag" refuses to use HEAD as a tagname
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 Dec 2024 02:32:40 +0000 (11:32 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Dec 2024 03:38:50 +0000 (12:38 +0900)
commitbbd445d5efd415d43ac6102a3e9541b9ac4f0329
tree80310da275a41a26c71d2e42dfbaa1003e635e06
parente5ce5b05d09c17c3d6a1d95c4c822dd3a73a9100
tag: "git tag" refuses to use HEAD as a tagname

Even though the plumbing level allows you to create refs/tags/HEAD
and refs/heads/HEAD, doing so makes it confusing within the context
of the UI Git Porcelain commands provides.  Just like we prevent a
branch from getting called "HEAD" at the Porcelain layer (i.e. "git
branch" command), teach "git tag" to refuse to create a tag "HEAD".

With a few new tests, we make sure that

 - "git tag HEAD" and "git tag -a HEAD" are rejected

 - "git update-ref refs/tags/HEAD" is still allowed (this is a
   deliberate design decision to allow others to create their own UI
   on top of Git infrastructure that may be different from our UI).

 - "git tag -d HEAD" can remove refs/tags/HEAD to recover from an
   mistake.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
t/t7004-tag.sh