]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Teach git-remote to update existing remotes by fetching from them
authorTheodore Ts'o <tytso@mit.edu>
Mon, 19 Feb 2007 04:00:00 +0000 (23:00 -0500)
committerJunio C Hamano <junkio@cox.net>
Tue, 20 Feb 2007 02:34:33 +0000 (18:34 -0800)
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>
Documentation/config.txt
Documentation/git-remote.txt
git-remote.perl

index 38655350f22bde08786b4a42e608ba76c1becea4..d8e696f4cd9f119d9368c08e91ccea9946c83b3b 100644 (file)
@@ -439,6 +439,10 @@ pull.octopus::
 pull.twohead::
        The default merge strategy to use when pulling a single branch.
 
+remote.fetch::
+       The list of remotes which are fetched by "git remote update".
+       See gitlink:git-remote[1].
+
 remote.<name>.url::
        The URL of a remote repository.  See gitlink:git-fetch[1] or
        gitlink:git-push[1].
index a60c31a3150ca8109b1fb16aaf8ff485b57c9932..06ba2e6f26aca732c70d04b6d59190dd0e3a683e 100644 (file)
@@ -13,6 +13,7 @@ SYNOPSIS
 'git-remote' add <name> <url>
 'git-remote' show <name>
 'git-remote' prune <name>
+'git-remote' update
 
 DESCRIPTION
 -----------
@@ -40,7 +41,14 @@ Gives some information about the remote <name>.
 
 Deletes all stale tracking branches under <name>.
 These stale branches have already been removed from the remote repository
-referenced by <name>, but are still locally available in "remotes/<name>".
+referenced by <name>, but are still locally available in
+"remotes/<name>".
+
+'update'::
+
+Fetch updates for the remotes in the repository.  By default all remotes
+are updated, but this can be configured via the configuration parameter
+'remote.fetch'.   (See gitlink:git-config[1]).
 
 
 DISCUSSION
index c56c5a84a4ac67648efd3c5ccf690e9cb21dd54f..6e473ecfd06b56524acca7d69dc0e8eff5b9c820 100755 (executable)
@@ -303,6 +303,18 @@ elsif ($ARGV[0] eq 'show') {
                show_remote($ARGV[$i], $ls_remote);
        }
 }
+elsif ($ARGV[0] eq 'update') {
+        my $conf = $git->config("remote.fetch");
+       if (defined($conf)) {
+               @remotes = split(' ', $conf);
+       } else {
+               @remotes = sort keys %$remote;
+       }
+       for (@remotes) {
+               print "Fetching $_\n";
+               $git->command('fetch', "$_");
+       }
+}
 elsif ($ARGV[0] eq 'prune') {
        my $ls_remote = 1;
        my $i;
@@ -360,5 +372,6 @@ else {
        print STDERR "       git remote add <name> <url>\n";
        print STDERR "       git remote show <name>\n";
        print STDERR "       git remote prune <name>\n";
+       print STDERR "       git remote update\n";
        exit(1);
 }