Re: [BUG] git fetch fetches tags matching negative refspec
- From
- Erik Cervin Edin <erik@cervined.in>
- Date
- Oct 18, 2022, 12:40 UTC
- Message-ID
- <CA+JQ7M_BoDbLM5_0Gvqfy0TTT_=4tvxG7mi+1ZYSNDTkSEoR6g@mail.gmail.com>
- In-Reply-To
- <xmqqlepjivv4.fsf@gitster.g>
On Thu, Oct 13, 2022 at 5:31 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> > 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".
Thank you for the clarification.
What follows is a small write-up of my problem for posterity and in-case someone else finds it useful.
What I'm trying to achieve is by default excluding a set of tags auto generated build tags from being fetched, unless I specifically fetch them.
Something akin to this works
[remote "origin"]
url = git@github.com:git/git.git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = ^refs/tags/v2.9.*
tagOpt = --no-tagsThis lets me git fetch git fetch origin master without fetching tags matching the negative refspec, as expected. As well as override it through git fetch origin '+refs/tags/v2.9.0*:refs/tags/v2.9.0*' which isn't super friendly to write but does the job
Earlier in the thread, I was under the impression --tags worked better than --no-tags. It seemed it would avoid clobbering tags. I don't think that's actually the case (they both clobber?) and it turned out it wouldn't exclude refs if I was fetching a specific ref, ie git fetch origin master would also fetch the tags I didn't want. So --no-tags it is