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"
  ...
This commit is contained in:
Junio C Hamano
2013-12-12 14:14:10 -08:00
14 changed files with 503 additions and 320 deletions

View File

@ -2087,8 +2087,8 @@ remote.<name>.vcs::
remote.<name>.prune::
When set to true, fetching from this remote by default will also
remove any remote-tracking branches which no longer exist on the
remote (as if the `--prune` option was give on the command line).
remove any remote-tracking references that no longer exist on the
remote (as if the `--prune` option was given on the command line).
Overrides `fetch.prune` settings, if any.
remotes.<group>::

View File

@ -41,17 +41,20 @@ ifndef::git-pull[]
-p::
--prune::
After fetching, remove any remote-tracking branches which
no longer exist on the remote.
After fetching, remove any remote-tracking references that no
longer exist on the remote. Tags are not subject to pruning
if they are fetched only because of the default tag
auto-following or due to a --tags option. However, if tags
are fetched due to an explicit refspec (either on the command
line or in the remote configuration, for example if the remote
was cloned with the --mirror option), then they are also
subject to pruning.
endif::git-pull[]
ifdef::git-pull[]
--no-tags::
endif::git-pull[]
ifndef::git-pull[]
-n::
--no-tags::
endif::git-pull[]
--no-tags::
By default, tags that point at objects that are downloaded
from the remote repository are fetched and stored locally.
This option disables this automatic tag following. The default
@ -61,11 +64,12 @@ endif::git-pull[]
ifndef::git-pull[]
-t::
--tags::
This is a short-hand for giving `refs/tags/*:refs/tags/*`
refspec from the command line, to ask all tags to be fetched
and stored locally. Because this acts as an explicit
refspec, the default refspecs (configured with the
remote.$name.fetch variable) are overridden and not used.
Fetch all tags from the remote (i.e., fetch remote tags
`refs/tags/*` into local tags with the same name), in addition
to whatever else would otherwise be fetched. Using this
option alone does not subject tags to pruning, even if --prune
is used (though tags may be pruned anyway if they are also the
destination of an explicit refspec; see '--prune').
--recurse-submodules[=yes|on-demand|no]::
This option controls if and under what conditions new commits of

View File

@ -24,13 +24,13 @@ The ref names and their object names of fetched refs are stored
in `.git/FETCH_HEAD`. This information is left for a later merge
operation done by 'git merge'.
When <refspec> stores the fetched result in remote-tracking branches,
the tags that point at these branches are automatically
followed. This is done by first fetching from the remote using
the given <refspec>s, and if the repository has objects that are
pointed by remote tags that it does not yet have, then fetch
those missing tags. If the other end has tags that point at
branches you are not interested in, you will not get them.
By default, tags are auto-followed. This means that when fetching
from a remote, any tags on the remote that point to objects that exist
in the local repository are fetched. The effect is to fetch tags that
point at branches that you are interested in. This default behavior
can be changed by using the --tags or --no-tags options, by
configuring remote.<name>.tagopt, or by using a refspec that fetches
tags explicitly.
'git fetch' can fetch from either a single named repository,
or from several repositories at once if <group> is given and

View File

@ -58,16 +58,16 @@ default remote, given the current branch and configuration.
struct refspec
--------------
A struct refspec holds the parsed interpretation of a refspec. If it
will force updates (starts with a '+'), force is true. If it is a
pattern (sides end with '*') pattern is true. src and dest are the two
sides (if a pattern, only the part outside of the wildcards); if there
is only one side, it is src, and dst is NULL; if sides exist but are
empty (i.e., the refspec either starts or ends with ':'), the
corresponding side is "".
A struct refspec holds the parsed interpretation of a refspec. If it
will force updates (starts with a '+'), force is true. If it is a
pattern (sides end with '*') pattern is true. src and dest are the
two sides (including '*' characters if present); if there is only one
side, it is src, and dst is NULL; if sides exist but are empty (i.e.,
the refspec either starts or ends with ':'), the corresponding side is
"".
This parsing can be done to an array of strings to give an array of
struct refpsecs with parse_ref_spec().
An array of strings can be parsed into an array of struct refspecs
using parse_fetch_refspec() or parse_push_refspec().
remote_find_tracking(), given a remote and a struct refspec with
either src or dst filled out, will fill out the other such that the