Subject: Re: [BUG] git fetch fetches tags matching negative refspec

From: Junio C Hamano <[email-masked]>
Date: Thu, 13 Oct 2022 08:30:55 -0700

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

> Because your refspec doesn't include refs/tags/*:, try e.g.:
>
> 	git fetch https://github.com/git/git.git 'refs/tags/*:refs/tags/*' --no-tags --dry-run
>
> That's what "--no-tags", i.e. it's per-se (and confusingly) nothing to
> do with whether you get tags or not, it's to do with whether we to tag
> following.

It indeed is confusing and might warrant some clarification, if not
updating.

 * "--tags" is equivalent to giving "refs/tags*:refs/tags*", so it
   might be natural to expect that you can say the same thing as
   above with "fetch $URL --tags --no-tags", but it does not work
   that way.  Command line parser treats "--tags" and "--no-tags" as
   if they follow the "last one wins" semantics.

 * As discussed in this thread, what "--no-tags" really means is "do
   not follow tags"; there is no way to countermand a "--no-tags"
   earlier on the command line to say "earlier we said do not
   follow, but we changed our mind.  Please do follow tags".

It would have been nice if we had from day one

 * "--tags": equivalent to writing "refs/tags/*:refs/tags/*"

 * "--no-tags": "earlier we said --tags, but we changed our
   mind. Please forget we earlier said --tags".

 * "--follow-tags": automatically fetch tags that point at an
   object that were fetched (default).

 * "--no-follow-tags": stop following tags.

but I do not think it is worth the churn and transition pain to
change it after more than 15 years.