git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
EEErik 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-tags
This 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
Previous: Junio C Hamano
Message 7 of 7 in “[BUG] git fetch fetches tags matching negative refspec”
  1. Erik Cervin EdinOct 12, 2022
  2. Ævar Arnfjörð BjarmasonOct 12, 2022
  3. Erik Cervin EdinOct 12, 2022
  4. Ævar Arnfjörð BjarmasonOct 12, 2022
  5. Erik Cervin EdinOct 13, 2022
  6. Junio C HamanoOct 13, 2022
  7. Erik Cervin EdinOct 18, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.