Allow git-remote to update named groups of remotes
In response to a feature request from Shawn Pearce, this patch allows a user to update a named group of remotes by using "git remote update <group>", where the group is defined in the config file by remotes.<group>. The default if the named group is not specified is now fetched group remotes.default, instead of remote.fetch, which is what had been previously used. In addition, if remotes.default is not defined, all remotes defined in the config file will be used, as before, but there is now also possible to request that a particular repository to be skipped by default by using the boolean configuration parameter remote.<name>.skipDefaultUpdate. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
Theodore Ts'o committed
Feb 20, 2007 at 15:13 UTC
1918278ea1019553b01297aad2caeed88e9092a4
3 files changed
+46
-17
Documentation/config.txt
+8
-4
@@ -439,10 +439,6 @@ pull.octopus::
439
pull.twohead::
440
The default merge strategy to use when pulling a single branch.
441
442
-remote.fetch::
443
- The list of remotes which are fetched by "git remote update".
444
- See gitlink:git-remote[1].
445
-
442
remote.<name>.url::
443
The URL of a remote repository. See gitlink:git-fetch[1] or
444
gitlink:git-push[1].
@@ -455,6 +451,10 @@ remote.<name>.push::
451
The default set of "refspec" for gitlink:git-push[1]. See
452
gitlink:git-push[1].
453
454
+remote.<name>.skipDefaultUpdate::
455
+ If true, this remote will be skipped by default when updating
456
+ using the remote subcommand of gitlink:git-remote[1].
457
+
458
remote.<name>.receivepack::
459
The default program to execute on the remote side when pushing. See
460
option \--exec of gitlink:git-push[1].
@@ -463,6 +463,10 @@ remote.<name>.uploadpack::
463
The default program to execute on the remote side when fetching. See
464
option \--exec of gitlink:git-fetch-pack[1].
465
466
+remotes.<group>::
467
+ The list of remotes which are fetched by "git remote update
468
+ <group>". See gitlink:git-remote[1].
469
+
470
repack.usedeltabaseoffset::
471
Allow gitlink:git-repack[1] to create packs that uses
472
delta-base offset. Defaults to false.
Documentation/git-remote.txt
+7
-4
@@ -13,7 +13,7 @@ SYNOPSIS
13
'git-remote' add <name> <url>
14
'git-remote' show <name>
15
'git-remote' prune <name>
16
-'git-remote' update
16
+'git-remote' update [group]
17
18
DESCRIPTION
19
-----------
@@ -46,9 +46,12 @@ referenced by <name>, but are still locally available in
46
47
'update'::
48
49
-Fetch updates for the remotes in the repository. By default all remotes
50
-are updated, but this can be configured via the configuration parameter
51
-'remote.fetch'. (See gitlink:git-config[1]).
49
+Fetch updates for a named set of remotes in the repository as defined by
50
+remotes.<group>. If a named group is not specified on the command line,
51
+the configuration parameter remotes.default will get used; if
52
+remotes.default is not defined, all remotes which do not the
53
+configuration parameter remote.<name>.skipDefaultUpdate set to true will
54
+be updated. (See gitlink:git-config[1]).
55
56
57
DISCUSSION
git-remote.perl
+31
-9
@@ -274,6 +274,31 @@ sub add_remote {
274
}
275
}
276
277
+sub update_remote {
278
+ my ($name) = @_;
279
+
280
+ my $conf = $git->config("remotes." . $name);
281
+ if (defined($conf)) {
282
+ @remotes = split(' ', $conf);
283
+ } elsif ($name eq 'default') {
284
+ undef @remotes;
285
+ for (sort keys %$remote) {
286
+ my $do_fetch = $git->config_boolean("remote." . $_ .
287
+ ".skipDefaultUpdate");
288
+ if (!defined($do_fetch) || $do_fetch ne "true") {
289
+ push @remotes, $_;
290
+ }
291
+ }
292
+ } else {
293
+ print STDERR "Remote group $name does not exists.\n";
294
+ exit(1);
295
+ }
296
+ for (@remotes) {
297
+ print "Updating $_\n";
298
+ $git->command('fetch', "$_");
299
+ }
300
+}
301
+
302
sub add_usage {
303
print STDERR "Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\n";
304
exit(1);
@@ -304,15 +329,12 @@ elsif ($ARGV[0] eq 'show') {
329
}
330
}
331
elsif ($ARGV[0] eq 'update') {
307
- my $conf = $git->config("remote.fetch");
308
- if (defined($conf)) {
309
- @remotes = split(' ', $conf);
310
- } else {
311
- @remotes = sort keys %$remote;
332
+ if (@ARGV <= 1) {
333
+ update_remote("default");
334
+ exit(1);
335
}
313
- for (@remotes) {
314
- print "Fetching $_\n";
315
- $git->command('fetch', "$_");
336
+ for ($i = 1; $i < @ARGV; $i++) {
337
+ update_remote($ARGV[$i]);
338
}
339
}
340
elsif ($ARGV[0] eq 'prune') {
@@ -372,6 +394,6 @@ else {
394
print STDERR " git remote add <name> <url>\n";
395
print STDERR " git remote show <name>\n";
396
print STDERR " git remote prune <name>\n";
375
- print STDERR " git remote update\n";
397
+ print STDERR " git remote update [group]\n";
398
exit(1);
399
}