From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Michael Giuffrida <michaelpg@chromium.org>,
Michael Schubert <mschub@elegosoft.com>,
Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 12/12] fetch: add a --fetch-prune option and fetch.pruneTags config
Date: Tue, 23 Jan 2018 00:48:02 +0100 [thread overview]
Message-ID: <87tvvdh2vh.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <xmqq372xmxcu.fsf@gitster.mtv.corp.google.com>
On Mon, Jan 22 2018, Junio C. Hamano jotted:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> Add a --fetch-prune option to git-fetch, along with fetch.pruneTags
>> config option. This allows for doing any of:
>>
>> git fetch -p -P
>> git fetch --prune --prune-tags
>> git fetch -p -P origin
>> git fetch --prune --prune-tags origin
>>
>> Or simply:
>>
>> git config fetch.prune true &&
>> git config fetch.pruneTags true &&
>> git fetch
>>
>> Instead of the much more verbose:
>>
>> git fetch --prune origin 'refs/tags/*:refs/tags/*' '+refs/heads/*:refs/remotes/origin/*'
>>
>> Before this feature it was painful to support the use-case of pulling
>> from a repo which is having both its branches *and* tags deleted
>> regularly, and wanting our local references to reflect upstream.
>>
>> At work we create deployment tags in the repo for each rollout, and
>> there's *lots* of those, so they're archived within weeks for
>> performance reasons.
>>
>> Without this change it's hard to centrally configure such repos in
>> /etc/gitconfig (on servers that are only used for working with
>> them). You need to set fetch.prune=true globally, and then for each
>> repo:
>>
>> git -C {} config --replace-all remote.origin.fetch "refs/tags/*:refs/tags/*" "^refs/tags/*:refs/tags/*$"
>
> I think the last one is supposed to be a regular expression on
> existing values. Shouldn't the asterisks be quoted?
>
> Otherwise, it would appears as if "refs/tags:refs/tags///" are
> replaced with "refs/tags/*:refs/tags/*", but it certainly is not
> what you are doing.
Yes, well spotted. I copied this from an escaped version and forgot to
update that escaping. Will fix.
> I also wonder why the existing one does not expect a leading '+',
> which I think is what we place by default when you clone.
I didn't raise this because I didn't want to get side-tracked with yet
another thing, but it appears to me that a + prefix in tags refspecs
does absolutely nothing. Consider on a fresh git.git clobbering the new
v2.16.1 tag locally:
$ git tag -a -m"fake" -f v2.16.1 v2.16.0
Updated tag 'v2.16.1' (was eb5fcb24f)
This should clobber it, and does:
$ git fetch --prune --dry-run origin '+refs/tags/*:refs/tags/*'
From github.com:git/git
t [tag update] v2.16.1 -> v2.16.1
But so will this without +, which seems like a bug to me:
$ git fetch --prune --dry-run origin 'refs/tags/*:refs/tags/*'
From github.com:git/git
t [tag update] v2.16.1 -> v2.16.1
But maybe I'm missing something.
>> +-P::
>> +--prune-tags::
>> + .... This option is
>> + merely a shorthand for providing the explicit tag refspec
>> + along with `--prune`, see the discussion about that in its
>> + documentation.
>
> So would "git fetch -P origin" be like "git fetch --prune --tags
> origin"?
No, as I understand it --tags just has the effect of considering remote
tags that aren't tags of the branches you're fetching, so e.g. on a
fresh git.git:
$ git tag -a -m"fake" -f v2.16.2 v2.16.0
$ git fetch --prune --tags --dry-run
$
I.e. it does nothing. Whereas this will prune the new fake tag:
$ git fetch --prune origin 'refs/tags/*:refs/tags/*'
From github.com:git/git
- [deleted] (none) -> v2.16.2
And so does the --prune-tags option:
$ ~/g/git/git-fetch --prune --prune-tags origin
From github.com:git/git
- [deleted] (none) -> v2.16.2
>> +
>> See the PRUNING section below for more details.
>>
>> diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
>> index 18fac0da2e..5682ed4ae1 100644
>> --- a/Documentation/git-fetch.txt
>> +++ b/Documentation/git-fetch.txt
>> @@ -148,6 +148,30 @@ So be careful when using this with a refspec like
>> `refs/tags/*:refs/tags/*`, or any other refspec which might map
>> references from multiple remotes to the same local namespace.
>>
>> +Since keeping up-to-date with both branches and tags on the remote is
>> +a common use-case the `--prune-tags` option can be supplied along with
>> +`--prune` to prune local tags that don't exist on the remote. Tag
>> +pruning can also be enabled with `fetch.pruneTags` or
>> +`remote.<name>.pruneTags` in the config. See linkgit:git-config[1].
>> +
>> +The `--prune-tags` option is equivalent to having
>> +`refs/tags/*:refs/tags/*` configured in the refspecs for the
>> +remote. This can lead to some seemingly strange interactions:
>> +
>> +------------------------------------------------
>> +# These both fetch tags
>> +$ git fetch --no-tags origin 'refs/tags/*:refs/tags/*'
>> +$ git fetch --no-tags --prune-tags origin
>> +------------------------------------------------
>
> This description is too confusing. First you say "having
> ... configured in the refspecs for the remote", but configured
> refspecs for the remote (I presume that you are missing 'fetch' from
> that description and are talking about the "remote.$name.fetch"
> configuration variable) are overridden when you give explicit
> refspecs from the command line, so the above two are not even
> equivalent. The first one gives a refspec explicitly from the
> command line, so other configured refspecs like
>
> [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/*
>
> should be ignored, while the second one, if --prune-tags tells Git
> to behave as if
>
> [remote "origin"] fetch = refs/tags/*:refs/tags/*
>
> also exists in the config, would not cause other ones for the same
> remote from getting ignored. So...
Indeed, I'll reword this. FWIW I meant something closer to "declared in
the refspecs of the remote" not "configured ... remote".
next prev parent reply other threads:[~2018-01-22 23:48 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 21:16 [BUG] git remote prune removes local tags, depending on fetch config Michael Giuffrida
2018-01-16 0:38 ` Ævar Arnfjörð Bjarmason
2018-01-16 2:14 ` Michael Giuffrida
2018-01-16 11:14 ` Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 00/11] document & test fetch pruning + WIP fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 00/12] document & test fetch pruning & add fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 00/11] " Ævar Arnfjörð Bjarmason
2018-01-24 23:04 ` Junio C Hamano
2018-01-24 23:25 ` Ævar Arnfjörð Bjarmason
2018-02-06 16:23 ` Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 00/17] " Ævar Arnfjörð Bjarmason
2018-02-08 18:21 ` Ævar Arnfjörð Bjarmason
2018-02-08 19:48 ` Junio C Hamano
2018-02-09 21:06 ` Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 01/17] fetch: don't redundantly NULL something calloc() gave us Ævar Arnfjörð Bjarmason
2018-02-09 4:36 ` Eric Sunshine
2018-02-09 19:06 ` Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 02/17] fetch: trivially refactor assignment to ref_nr Ævar Arnfjörð Bjarmason
2018-02-09 4:41 ` Eric Sunshine
2018-02-08 16:19 ` [PATCH v2 03/17] fetch: stop accessing "remote" variable indirectly Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 04/17] remote: add a macro for "refs/tags/*:refs/tags/*" Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 05/17] fetch tests: refactor in preparation for testing tag pruning Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 06/17] fetch tests: re-arrange arguments for future readability Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 07/17] fetch tests: add a tag to be deleted to the pruning tests Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 08/17] fetch tests: test --prune and refspec interaction Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 09/17] fetch tests: double quote a variable for interpolation Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 10/17] fetch tests: expand case/esac for later change Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 11/17] fetch tests: fetch <url> <spec> as well as fetch [<remote>] Ævar Arnfjörð Bjarmason
2018-02-09 5:17 ` Eric Sunshine
2018-02-09 20:05 ` Ævar Arnfjörð Bjarmason
2018-02-09 20:27 ` Jeff King
2018-02-09 21:14 ` Eric Sunshine
2018-02-09 20:57 ` Junio C Hamano
2018-02-09 21:13 ` Junio C Hamano
2018-02-08 16:19 ` [PATCH v2 12/17] git fetch doc: add a new section to explain the ins & outs of pruning Ævar Arnfjörð Bjarmason
2018-02-09 5:26 ` Eric Sunshine
2018-02-08 16:19 ` [PATCH v2 13/17] git remote doc: correct dangerous lies about what prune does Ævar Arnfjörð Bjarmason
2018-02-09 5:33 ` Eric Sunshine
2018-02-08 16:19 ` [PATCH v2 14/17] git-fetch & config doc: link to the new PRUNING section Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 15/17] fetch tests: add scaffolding for the new fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 16/17] fetch: add a --fetch-prune option and fetch.pruneTags config Ævar Arnfjörð Bjarmason
2018-02-09 6:58 ` Eric Sunshine
2018-02-09 8:23 ` Ævar Arnfjörð Bjarmason
2018-02-08 16:19 ` [PATCH v2 17/17] fetch: make the --fetch-prune work with <url> Ævar Arnfjörð Bjarmason
2018-02-09 7:03 ` Eric Sunshine
2018-02-09 8:22 ` Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 01/11] fetch: don't redundantly NULL something calloc() gave us Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 02/11] fetch: stop accessing "remote" variable indirectly Ævar Arnfjörð Bjarmason
2018-01-24 20:53 ` Junio C Hamano
2018-01-23 22:13 ` [PATCH v3 03/11] fetch tests: refactor in preparation for testing tag pruning Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 04/11] fetch tests: re-arrange arguments for future readability Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 05/11] fetch tests: add a tag to be deleted to the pruning tests Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 06/11] fetch tests: test --prune and refspec interaction Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 07/11] git fetch doc: add a new section to explain the ins & outs of pruning Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 08/11] git remote doc: correct dangerous lies about what prune does Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 09/11] git-fetch & config doc: link to the new PRUNING section Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 10/11] fetch tests: add scaffolding for the new fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-01-23 22:13 ` [PATCH v3 11/11] fetch: add a --fetch-prune option and fetch.pruneTags config Ævar Arnfjörð Bjarmason
2018-01-24 20:52 ` Junio C Hamano
2018-01-24 21:03 ` Ævar Arnfjörð Bjarmason
2018-01-24 21:15 ` Junio C Hamano
2018-02-09 20:31 ` [PATCH v5 00/17] document & test fetch pruning & add fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-02-22 0:23 ` Junio C Hamano
2018-02-22 14:18 ` Ævar Arnfjörð Bjarmason
2018-02-22 20:09 ` Junio C Hamano
2018-02-23 9:04 ` Ævar Arnfjörð Bjarmason
2018-02-23 21:10 ` Junio C Hamano
2018-02-24 21:42 ` Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 01/17] fetch: don't redundantly NULL something calloc() gave us Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 02/17] fetch: trivially refactor assignment to ref_nr Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 03/17] fetch: stop accessing "remote" variable indirectly Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 04/17] remote: add a macro for "refs/tags/*:refs/tags/*" Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 05/17] fetch tests: refactor in preparation for testing tag pruning Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 06/17] fetch tests: re-arrange arguments for future readability Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 07/17] fetch tests: add a tag to be deleted to the pruning tests Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 08/17] fetch tests: test --prune and refspec interaction Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 09/17] fetch tests: double quote a variable for interpolation Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 10/17] fetch tests: expand case/esac for later change Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 11/17] fetch tests: fetch <url> <spec> as well as fetch [<remote>] Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 12/17] git fetch doc: add a new section to explain the ins & outs of pruning Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 13/17] git remote doc: correct dangerous lies about what prune does Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 14/17] git-fetch & config doc: link to the new PRUNING section Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 15/17] fetch tests: add scaffolding for the new fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 16/17] fetch: add a --prune-tags option and fetch.pruneTags config Ævar Arnfjörð Bjarmason
2018-02-09 20:32 ` [PATCH v5 17/17] fetch: make the --prune-tags work with <url> Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 01/12] fetch tests: refactor in preparation for testing tag pruning Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 02/12] fetch tests: arrange arguments for future readability Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 03/12] fetch tests: add a tag to be deleted to the pruning tests Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 04/12] fetch tests: double quote a variable for interpolation Ævar Arnfjörð Bjarmason
2018-01-22 19:52 ` Junio C Hamano
2018-01-22 23:04 ` Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 05/12] fetch tests: test --prune and refspec interaction Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 06/12] git fetch doc: add a new section to explain the ins & outs of pruning Ævar Arnfjörð Bjarmason
2018-01-21 0:02 ` [PATCH v2 07/12] git remote doc: correct dangerous lies about what prune does Ævar Arnfjörð Bjarmason
2018-01-22 20:01 ` Junio C Hamano
2018-01-22 23:05 ` Ævar Arnfjörð Bjarmason
2018-01-21 0:03 ` [PATCH v2 08/12] git-fetch & config doc: link to the new PRUNING section Ævar Arnfjörð Bjarmason
2018-01-21 0:03 ` [PATCH v2 09/12] fetch: don't redundantly NULL something calloc() gave us Ævar Arnfjörð Bjarmason
2018-01-21 8:25 ` Ævar Arnfjörð Bjarmason
2018-01-21 0:03 ` [PATCH v2 10/12] fetch: stop accessing "remote" variable indirectly Ævar Arnfjörð Bjarmason
2018-01-21 0:03 ` [PATCH v2 11/12] fetch tests: add scaffolding for the new fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-01-21 0:03 ` [PATCH v2 12/12] fetch: add a --fetch-prune option and fetch.pruneTags config Ævar Arnfjörð Bjarmason
2018-01-22 20:50 ` Junio C Hamano
2018-01-22 23:48 ` Ævar Arnfjörð Bjarmason [this message]
2018-01-19 0:00 ` [PATCH 01/11] fetch tests: refactor in preparation for testing tag pruning Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 02/11] fetch tests: arrange arguments for future readability Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 03/11] fetch tests: add a tag to be deleted to the pruning tests Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 04/11] fetch tests: double quote a variable for interpolation Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 05/11] fetch tests: test --prune and refspec interaction Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 06/11] git fetch doc: add a new section to explain the ins & outs of pruning Ævar Arnfjörð Bjarmason
2018-01-19 0:46 ` Eric Sunshine
2018-01-19 0:00 ` [PATCH 07/11] git remote doc: correct dangerous lies about what prune does Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 08/11] git-fetch & config doc: link to the new PRUNING section Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 09/11] fetch: don't redundantly null something calloc() gave us Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [PATCH 10/11] fetch tests: add scaffolding for the new fetch.pruneTags Ævar Arnfjörð Bjarmason
2018-01-19 0:00 ` [RFC/PATCH 11/11] WIP fetch: add a --fetch-prune option and fetch.pruneTags config Ævar Arnfjörð Bjarmason
2018-01-16 11:48 ` [BUG] git remote prune removes local tags, depending on fetch config Andreas Schwab
2018-01-18 6:18 ` Kevin Daudt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tvvdh2vh.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=michaelpg@chromium.org \
--cc=mschub@elegosoft.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.