From: Theodore Ts'o Date: Mon, 19 Feb 2007 04:00:00 +0000 (-0500) Subject: Teach git-remote to update existing remotes by fetching from them X-Git-Tag: v1.5.1-rc1~277 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1e592d65b50dbec87fde9f4ef1b7fd8d90bf7b8c;p=git.git 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" Signed-off-by: Junio C Hamano --- diff --git a/Documentation/config.txt b/Documentation/config.txt index 38655350f..d8e696f4c 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -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..url:: The URL of a remote repository. See gitlink:git-fetch[1] or gitlink:git-push[1]. diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index a60c31a31..06ba2e6f2 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -13,6 +13,7 @@ SYNOPSIS 'git-remote' add 'git-remote' show 'git-remote' prune +'git-remote' update DESCRIPTION ----------- @@ -40,7 +41,14 @@ Gives some information about the remote . Deletes all stale tracking branches under . These stale branches have already been removed from the remote repository -referenced by , but are still locally available in "remotes/". +referenced by , but are still locally available in +"remotes/". + +'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 diff --git a/git-remote.perl b/git-remote.perl index c56c5a84a..6e473ecfd 100755 --- a/git-remote.perl +++ b/git-remote.perl @@ -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 \n"; print STDERR " git remote show \n"; print STDERR " git remote prune \n"; + print STDERR " git remote update\n"; exit(1); }