Skip to contentSkip to conversation

Teach the --all option to 'git fetch'

PATCH New Björn Gustavsson 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 Teach the --all option to 'git fetch'

'git remote' is meant for managing remotes and 'git fetch' is meant for actually fetching data from remote repositories. Therefore, it is not logical that you must use 'git remote update' to fetch from more than one repository at once.

Add the --all option to 'git fetch', to tell it to attempt to fetch from all remotes. Also, if --all is not given, the <repository> argument is allowed to be the name of a group, to allow fetching from all repositories in the group.

Other options except -v and -q are silently ignored.

---
 Documentation/fetch-options.txt    |    3 +
 Documentation/git-fetch.txt        |   12 +++-
 Documentation/pull-fetch-param.txt |    7 ++
 builtin-fetch.c                    |  150 +++++++++++++++++++++++++++++++----
 t/t5506-remote-groups.sh           |   21 +++++-
 t/t5514-fetch-multiple.sh          |   76 ++++++++++++++++++
 6 files changed, 247 insertions(+), 22 deletions(-)
 create mode 100755 t/t5514-fetch-multiple.sh
Documentation/fetch-options.txt +3 -0
index 2886874..93d73c3 100644
@@ -1,3 +1,6 @@
+--all::
+	Fetch all remotes.
+
 -a::
 --append::
 	Append ref names and object names of fetched refs to the
Documentation/git-fetch.txt +10 -2
index f2483d6..3616466 100644
@@ -10,11 +10,15 @@ SYNOPSIS
 --------
 'git fetch' <options> <repository> <refspec>...
 
+'git fetch' <options> <group>
+
+'git fetch' --all <options>
+
 
 DESCRIPTION
 -----------
-Fetches named heads or tags from another repository, along with
-the objects necessary to complete them.
+Fetches named heads or tags from one or more other repositories,
+along with the objects necessary to complete them.
 
 The ref names and their object names of fetched refs are stored
 in `.git/FETCH_HEAD`.  This information is left for a later merge
@@ -28,6 +32,10 @@ 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.
 
+'git fetch' can fetch from either a single named repository, or
+or from several repositories at once if <group> is given and
+there is a remotes.<group> entry in the configuration file.
+(See linkgit:git-config[1]).
 
 OPTIONS
 -------
Documentation/pull-fetch-param.txt +7 -0
index f9811f2..712b91a 100644
@@ -4,6 +4,13 @@
 	(see the section <<URLS,GIT URLS>> below) or the name
 	of a remote (see the section <<REMOTES,REMOTES>> below).
 
+ifndef::git-pull[]
+<group>::
+	A name referring to a list of repositories as the value
+	of remotes.<group> in the configuration file.
+	(See linkgit:git-config[1]).
+endif::git-pull[]
+
 <refspec>::
 	The format of a <refspec> parameter is an optional plus
 	`{plus}`, followed by the source ref <src>, followed
builtin-fetch.c +132 -18

191 lines not on this page · raw message

t/t5506-remote-groups.sh +19 -2
index 2a1806b..b7b7dda 100755
@@ -51,7 +51,7 @@ test_expect_success 'nonexistant group produces error' '
 	! repo_fetched two
 '
 
-test_expect_success 'updating group updates all members' '
+test_expect_success 'updating group updates all members (remote update)' '
 	mark group-all &&
 	update_repos &&
 	git config --add remotes.all one &&
@@ -61,7 +61,15 @@ test_expect_success 'updating group updates all members' '
 	repo_fetched two
 '
 
-test_expect_success 'updating group does not update non-members' '
+test_expect_success 'updating group updates all members (fetch)' '
+	mark fetch-group-all &&
+	update_repos &&
+	git fetch all &&
+	repo_fetched one &&
+	repo_fetched two
+'
+
+test_expect_success 'updating group does not update non-members (remote update)' '
 	mark group-some &&
 	update_repos &&
 	git config --add remotes.some one &&
@@ -70,6 +78,15 @@ test_expect_success 'updating group does not update non-members' '
 	! repo_fetched two
 '
 
+test_expect_success 'updating group does not update non-members (fetch)' '
+	mark fetch-group-some &&
+	update_repos &&
+	git config --add remotes.some one &&
+	git remote update some &&
+	repo_fetched one &&
+	! repo_fetched two
+'
+
 test_expect_success 'updating remote name updates that remote' '
 	mark remote-name &&
 	update_repos &&
t/t5514-fetch-multiple.sh new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.6.5.1.69.g36942