Skip to content

Commit e66ef7a

Browse files
committed
Merge branch 'mh/fetch-tags-in-addition-to-normal-refs'
The "--tags" option to "git fetch" used to be literally a synonym to a "refs/tags/*:refs/tags/*" refspec, which meant that (1) as an explicit refspec given from the command line, it silenced the lazy "git fetch" default that is configured, and (2) also as an explicit refspec given from the command line, it interacted with "--prune" to remove any tag that the remote we are fetching from does not have. This demotes it to an option; with it, we fetch all tags in addition to what would be fetched without the option, and it does not interact with the decision "--prune" makes to see what remote-tracking refs the local has are missing the remote counterpart. * mh/fetch-tags-in-addition-to-normal-refs: (23 commits) fetch: improve the error messages emitted for conflicting refspecs handle_duplicate(): mark error message for translation ref_remote_duplicates(): extract a function handle_duplicate() ref_remove_duplicates(): simplify loop logic t5536: new test of refspec conflicts when fetching ref_remove_duplicates(): avoid redundant bisection git-fetch.txt: improve description of tag auto-following fetch-options.txt: simplify ifdef/ifndef/endif usage fetch, remote: properly convey --no-prune options to subprocesses builtin/remote.c:update(): use struct argv_array builtin/remote.c: reorder function definitions query_refspecs(): move some constants out of the loop fetch --prune: prune only based on explicit refspecs fetch --tags: fetch tags *in addition to* other stuff fetch: only opportunistically update references based on command line get_expanded_map(): avoid memory leak get_expanded_map(): add docstring builtin/fetch.c: reorder function definitions get_ref_map(): rename local variables api-remote.txt: correct section "struct refspec" ...
2 parents 3d252a9 + f096e6e commit e66ef7a

14 files changed

+503
-320
lines changed

Documentation/config.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,8 +2087,8 @@ remote.<name>.vcs::
20872087

20882088
remote.<name>.prune::
20892089
When set to true, fetching from this remote by default will also
2090-
remove any remote-tracking branches which no longer exist on the
2091-
remote (as if the `--prune` option was give on the command line).
2090+
remove any remote-tracking references that no longer exist on the
2091+
remote (as if the `--prune` option was given on the command line).
20922092
Overrides `fetch.prune` settings, if any.
20932093

20942094
remotes.<group>::

Documentation/fetch-options.txt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ ifndef::git-pull[]
4141

4242
-p::
4343
--prune::
44-
After fetching, remove any remote-tracking branches which
45-
no longer exist on the remote.
44+
After fetching, remove any remote-tracking references that no
45+
longer exist on the remote. Tags are not subject to pruning
46+
if they are fetched only because of the default tag
47+
auto-following or due to a --tags option. However, if tags
48+
are fetched due to an explicit refspec (either on the command
49+
line or in the remote configuration, for example if the remote
50+
was cloned with the --mirror option), then they are also
51+
subject to pruning.
4652
endif::git-pull[]
4753

48-
ifdef::git-pull[]
49-
--no-tags::
50-
endif::git-pull[]
5154
ifndef::git-pull[]
5255
-n::
53-
--no-tags::
5456
endif::git-pull[]
57+
--no-tags::
5558
By default, tags that point at objects that are downloaded
5659
from the remote repository are fetched and stored locally.
5760
This option disables this automatic tag following. The default
@@ -61,11 +64,12 @@ endif::git-pull[]
6164
ifndef::git-pull[]
6265
-t::
6366
--tags::
64-
This is a short-hand for giving `refs/tags/*:refs/tags/*`
65-
refspec from the command line, to ask all tags to be fetched
66-
and stored locally. Because this acts as an explicit
67-
refspec, the default refspecs (configured with the
68-
remote.$name.fetch variable) are overridden and not used.
67+
Fetch all tags from the remote (i.e., fetch remote tags
68+
`refs/tags/*` into local tags with the same name), in addition
69+
to whatever else would otherwise be fetched. Using this
70+
option alone does not subject tags to pruning, even if --prune
71+
is used (though tags may be pruned anyway if they are also the
72+
destination of an explicit refspec; see '--prune').
6973

7074
--recurse-submodules[=yes|on-demand|no]::
7175
This option controls if and under what conditions new commits of

Documentation/git-fetch.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ The ref names and their object names of fetched refs are stored
2424
in `.git/FETCH_HEAD`. This information is left for a later merge
2525
operation done by 'git merge'.
2626

27-
When <refspec> stores the fetched result in remote-tracking branches,
28-
the tags that point at these branches are automatically
29-
followed. This is done by first fetching from the remote using
30-
the given <refspec>s, and if the repository has objects that are
31-
pointed by remote tags that it does not yet have, then fetch
32-
those missing tags. If the other end has tags that point at
33-
branches you are not interested in, you will not get them.
27+
By default, tags are auto-followed. This means that when fetching
28+
from a remote, any tags on the remote that point to objects that exist
29+
in the local repository are fetched. The effect is to fetch tags that
30+
point at branches that you are interested in. This default behavior
31+
can be changed by using the --tags or --no-tags options, by
32+
configuring remote.<name>.tagopt, or by using a refspec that fetches
33+
tags explicitly.
3434

3535
'git fetch' can fetch from either a single named repository,
3636
or from several repositories at once if <group> is given and

Documentation/technical/api-remote.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ default remote, given the current branch and configuration.
5858
struct refspec
5959
--------------
6060

61-
A struct refspec holds the parsed interpretation of a refspec. If it
62-
will force updates (starts with a '+'), force is true. If it is a
63-
pattern (sides end with '*') pattern is true. src and dest are the two
64-
sides (if a pattern, only the part outside of the wildcards); if there
65-
is only one side, it is src, and dst is NULL; if sides exist but are
66-
empty (i.e., the refspec either starts or ends with ':'), the
67-
corresponding side is "".
68-
69-
This parsing can be done to an array of strings to give an array of
70-
struct refpsecs with parse_ref_spec().
61+
A struct refspec holds the parsed interpretation of a refspec. If it
62+
will force updates (starts with a '+'), force is true. If it is a
63+
pattern (sides end with '*') pattern is true. src and dest are the
64+
two sides (including '*' characters if present); if there is only one
65+
side, it is src, and dst is NULL; if sides exist but are empty (i.e.,
66+
the refspec either starts or ends with ':'), the corresponding side is
67+
"".
68+
69+
An array of strings can be parsed into an array of struct refspecs
70+
using parse_fetch_refspec() or parse_push_refspec().
7171

7272
remote_find_tracking(), given a remote and a struct refspec with
7373
either src or dst filled out, will fill out the other such that the

0 commit comments

Comments
 (0)