* [BUG] git fetch fetches tags matching negative refspec
@ 2022-10-12 8:29 Erik Cervin Edin
2022-10-12 9:11 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 7+ messages in thread
From: Erik Cervin Edin @ 2022-10-12 8:29 UTC (permalink / raw)
To: Git Mailing List
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 = git@github.com:git/git.git
fetch = +refs/heads/*:refs/remotes/origin/*
By adding a negative respec for tags matching v2.9.*
[remote "origin"]
url = git@github.com: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.
[System Info]
git version:
git version 2.38.0.windows.1
cpu: x86_64
built from commit: 0355083fbe5582f6d3f819afc130ed2f2375e0bd
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Windows 10.0 19044
compiler info: gnuc: 12.2
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Users\erik\Git\usr\bin\bash.exe
[Enabled Hooks]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git fetch fetches tags matching negative refspec
2022-10-12 8:29 [BUG] git fetch fetches tags matching negative refspec Erik Cervin Edin
@ 2022-10-12 9:11 ` Ævar Arnfjörð Bjarmason
2022-10-12 15:10 ` Erik Cervin Edin
0 siblings, 1 reply; 7+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-10-12 9:11 UTC (permalink / raw)
To: Erik Cervin Edin; +Cc: Git Mailing List
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 = git@github.com:git/git.git
> fetch = +refs/heads/*:refs/remotes/origin/*
>
> By adding a negative respec for tags matching v2.9.*
> [remote "origin"]
> url = git@github.com: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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git fetch fetches tags matching negative refspec
2022-10-12 9:11 ` Ævar Arnfjörð Bjarmason
@ 2022-10-12 15:10 ` Erik Cervin Edin
2022-10-12 23:09 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 7+ messages in thread
From: Erik Cervin Edin @ 2022-10-12 15:10 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: Git Mailing List
On Wed, Oct 12, 2022 at 11:13 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> 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.
I tried but
git fetch --no-tags
with negative refspec did not fetch any tags.
git fetch --tags
does.
I'm going to set
git config remote.origin.tagopt --tags
and then that's going to do what I want.
Thank you for pointing me in the right direction and giving clarity.
> 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.
I guess then everything works as expected but maybe the documentation
regarding this could be improved.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git fetch fetches tags matching negative refspec
2022-10-12 15:10 ` Erik Cervin Edin
@ 2022-10-12 23:09 ` Ævar Arnfjörð Bjarmason
2022-10-13 8:15 ` Erik Cervin Edin
2022-10-13 15:30 ` Junio C Hamano
0 siblings, 2 replies; 7+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-10-12 23:09 UTC (permalink / raw)
To: Erik Cervin Edin; +Cc: Git Mailing List
On Wed, Oct 12 2022, Erik Cervin Edin wrote:
> On Wed, Oct 12, 2022 at 11:13 AM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> 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.
> I tried but
> git fetch --no-tags
> with negative refspec did not fetch any tags.
> git fetch --tags
> does.
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.
> I'm going to set
> git config remote.origin.tagopt --tags
> and then that's going to do what I want.
Isn't that going to give you also the tags you don't want?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git fetch fetches tags matching negative refspec
2022-10-12 23:09 ` Ævar Arnfjörð Bjarmason
@ 2022-10-13 8:15 ` Erik Cervin Edin
2022-10-13 15:30 ` Junio C Hamano
1 sibling, 0 replies; 7+ messages in thread
From: Erik Cervin Edin @ 2022-10-13 8:15 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: Git Mailing List
On Thu, Oct 13, 2022 at 1:11 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
>
> On Wed, Oct 12 2022, Erik Cervin Edin wrote:
>
> > On Wed, Oct 12, 2022 at 11:13 AM Ævar Arnfjörð Bjarmason
> > <avarab@gmail.com> wrote:
> >> 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.
> > I tried but
> > git fetch --no-tags
> > with negative refspec did not fetch any tags.
> > git fetch --tags
> > does.
>
> 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.
Kind of, adding the tags refspec with --no-tags excludes tags matching
the negative refspec but it also clobbers existing tags.
>
> > I'm going to set
> > git config remote.origin.tagopt --tags
> > and then that's going to do what I want.
>
> Isn't that going to give you also the tags you don't want?
No, it excludes them fine. It also doesn't clobber which fits my use-case best
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git fetch fetches tags matching negative refspec
2022-10-12 23:09 ` Ævar Arnfjörð Bjarmason
2022-10-13 8:15 ` Erik Cervin Edin
@ 2022-10-13 15:30 ` Junio C Hamano
2022-10-18 12:40 ` Erik Cervin Edin
1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2022-10-13 15:30 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: Erik Cervin Edin, Git Mailing List
Ævar Arnfjörð Bjarmason <avarab@gmail.com> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git fetch fetches tags matching negative refspec
2022-10-13 15:30 ` Junio C Hamano
@ 2022-10-18 12:40 ` Erik Cervin Edin
0 siblings, 0 replies; 7+ messages in thread
From: Erik Cervin Edin @ 2022-10-18 12:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ævar Arnfjörð Bjarmason, Git Mailing List
On Thu, Oct 13, 2022 at 5:31 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-18 12:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 8:29 [BUG] git fetch fetches tags matching negative refspec Erik Cervin Edin
2022-10-12 9:11 ` Ævar Arnfjörð Bjarmason
2022-10-12 15:10 ` Erik Cervin Edin
2022-10-12 23:09 ` Ævar Arnfjörð Bjarmason
2022-10-13 8:15 ` Erik Cervin Edin
2022-10-13 15:30 ` Junio C Hamano
2022-10-18 12:40 ` Erik Cervin Edin
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).