Skip to content

Commit 7cc91a2

Browse files
bjornggitster
authored andcommitted
Add the configuration option skipFetchAll
Implement the configuration skipFetchAll option to allow certain remotes to be skipped when doing 'git fetch --all' and 'git remote update'. The existing skipDefaultUpdate variable is still honored (by 'git fetch --all' and 'git remote update'). (If both are set in the configuration file with different values, the value of the last occurrence will be used.) Signed-off-by: Björn Gustavsson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16679e3 commit 7cc91a2

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

Documentation/config.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,13 @@ remote.<name>.mirror::
13811381

13821382
remote.<name>.skipDefaultUpdate::
13831383
If true, this remote will be skipped by default when updating
1384-
using the update subcommand of linkgit:git-remote[1].
1384+
using linkgit:git-fetch[1] or the `update` subcommand of
1385+
linkgit:git-remote[1].
1386+
1387+
remote.<name>.skipFetchAll::
1388+
If true, this remote will be skipped by default when updating
1389+
using linkgit:git-fetch[1] or the `update` subcommand of
1390+
linkgit:git-remote[1].
13851391

13861392
remote.<name>.receivepack::
13871393
The default program to execute on the remote side when pushing. See

builtin-fetch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ static void set_option(const char *name, const char *value)
649649
static int get_one_remote_for_fetch(struct remote *remote, void *priv)
650650
{
651651
struct string_list *list = priv;
652-
string_list_append(remote->name, list);
652+
if (!remote->skip_default_update)
653+
string_list_append(remote->name, list);
653654
return 0;
654655
}
655656

remote.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ static int handle_config(const char *key, const char *value, void *cb)
396396
remote->mirror = git_config_bool(key, value);
397397
else if (!strcmp(subkey, ".skipdefaultupdate"))
398398
remote->skip_default_update = git_config_bool(key, value);
399-
399+
else if (!strcmp(subkey, ".skipfetchall"))
400+
remote->skip_default_update = git_config_bool(key, value);
400401
else if (!strcmp(subkey, ".url")) {
401402
const char *v;
402403
if (git_config_string(&v, key, value))

t/t5514-fetch-multiple.sh

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ test_expect_success 'git fetch --multiple (but only one remote)' '
9494
cat > expect << EOF
9595
one/master
9696
one/side
97-
origin/HEAD -> origin/master
98-
origin/master
99-
origin/side
10097
two/another
10198
two/master
10299
two/side
@@ -105,6 +102,7 @@ EOF
105102
test_expect_success 'git fetch --multiple (two remotes)' '
106103
(git clone one test4 &&
107104
cd test4 &&
105+
git remote rm origin &&
108106
git remote add one ../one &&
109107
git remote add two ../two &&
110108
git fetch --multiple one two &&
@@ -117,4 +115,40 @@ test_expect_success 'git fetch --multiple (bad remote names)' '
117115
test_must_fail git fetch --multiple four)
118116
'
119117

118+
119+
test_expect_success 'git fetch --all (skipFetchAll)' '
120+
(cd test4 &&
121+
for b in $(git branch -r)
122+
do
123+
git branch -r -d $b || break
124+
done &&
125+
git remote add three ../three &&
126+
git config remote.three.skipFetchAll true &&
127+
git fetch --all &&
128+
git branch -r > output &&
129+
test_cmp ../expect output)
130+
'
131+
132+
cat > expect << EOF
133+
one/master
134+
one/side
135+
three/another
136+
three/master
137+
three/side
138+
two/another
139+
two/master
140+
two/side
141+
EOF
142+
143+
test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
144+
(cd test4 &&
145+
for b in $(git branch -r)
146+
do
147+
git branch -r -d $b || break
148+
done &&
149+
git fetch --multiple one two three &&
150+
git branch -r > output &&
151+
test_cmp ../expect output)
152+
'
153+
120154
test_done

0 commit comments

Comments
 (0)