@matheusbsbs / matheus-bagliano / commits / 1e592d65b5
Fork 0

Teach git-remote to update existing remotes by fetching from them

This allows users to use the command "git remote update" to update all remotes that are being tracked in the repository. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>

Theodore Ts'o committed Feb 18, 2007 at 23:00 UTC 1e592d65b50dbec87fde9f4ef1b7fd8d90bf7b8c
3 files changed +26 -1
Documentation/config.txt
+4
@@ -439,6 +439,10 @@ 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 +
446 remote.<name>.url::
447 The URL of a remote repository. See gitlink:git-fetch[1] or
448 gitlink:git-push[1].
Documentation/git-remote.txt
+9 -1
@@ -13,6 +13,7 @@ SYNOPSIS
13 'git-remote' add <name> <url>
14 'git-remote' show <name>
15 'git-remote' prune <name>
16 +'git-remote' update
17
18 DESCRIPTION
19 -----------
@@ -40,7 +41,14 @@ Gives some information about the remote <name>.
41
42 Deletes all stale tracking branches under <name>.
43 These stale branches have already been removed from the remote repository
43 -referenced by <name>, but are still locally available in "remotes/<name>".
44 +referenced by <name>, but are still locally available in
45 +"remotes/<name>".
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]).
52
53
54 DISCUSSION
git-remote.perl
+13
@@ -303,6 +303,18 @@ elsif ($ARGV[0] eq 'show') {
303 show_remote($ARGV[$i], $ls_remote);
304 }
305 }
306 +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;
312 + }
313 + for (@remotes) {
314 + print "Fetching $_\n";
315 + $git->command('fetch', "$_");
316 + }
317 +}
318 elsif ($ARGV[0] eq 'prune') {
319 my $ls_remote = 1;
320 my $i;
@@ -360,5 +372,6 @@ else {
372 print STDERR " git remote add <name> <url>\n";
373 print STDERR " git remote show <name>\n";
374 print STDERR " git remote prune <name>\n";
375 + print STDERR " git remote update\n";
376 exit(1);
377 }