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

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Wed, 12 Oct 2022 11:11:47 +0200

On Wed, Oct 12 2022, Erik Cervin Edin wrote:

> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> Delete all v2.9.* tags
>   git tag | grep ^v2.9.* | xargs git tag -d
>
> Change standard the standard fetch configuration
> [remote "origin"]
>     url = [email-masked]:git/git.git
>     fetch = +refs/heads/*:refs/remotes/origin/*
>
> By adding a negative respec for tags matching v2.9.*
> [remote "origin"]
>     url = [email-masked]:git/git.git
>     fetch = +refs/heads/*:refs/remotes/origin/*
>     fetch = ^refs/tags/v2.9.*
>
> run
>   git fetch
>
> What did you expect to happen? (Expected behavior)
>
> To exclude tags matchings v2.9*, just like when running git fetch --tags
>
> What happened instead? (Actual behavior)
>
> Without specifying git fetch --tags, tags matching the negative
> refspec are still fetched
>
> What's different between what you expected and what actually happened?
>
> The negative refspec appears to be ignored or overruled when running
> git fetch without the --tags flag
>
> Anything else you want to add:
> I love git, thank you! ♥
>
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.

I haven't had time to try this, but I believe this isn't a bug, it's
just that you didn't supply --no-tags.

"But I want some tags!", yes, that's not what --no-tags does, see the
2nd paragraph of the DESCRIPTION section of "git-fetch".

I.e. it got stuff you asked for, but also tags pointing at the main
history, --no-tags will stop that, at which point you can *also* fetch
tags, just with the refspec.