git remote update: Fallback to remote if group does not exist
authorFinn Arne Gangstad <finnag@pvv.org>
Mon, 6 Apr 2009 13:41:02 +0000 (15:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Apr 2009 04:52:26 +0000 (21:52 -0700)
Previously, git remote update <remote> would fail unless there was
a remote group configured with the same name as the remote.
git remote update will now fall back to using the remote if no matching
group can be found.

This enables "git remote update -p <remote>..." to fetch and prune one
or more remotes, for example.

Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-remote.txt
builtin-remote.c
index 0b6e67dbca2ed3c17222fd80007ddf42e7e8222f..9e2b4eaa385db66ffe0c547f0452d29e9e3dc484 100644 (file)
@@ -16,7 +16,7 @@ SYNOPSIS
 'git remote set-head' <name> [-a | -d | <branch>]
 'git remote show' [-n] <name>
 'git remote prune' [-n | --dry-run] <name>
-'git remote update' [-p | --prune] [group]
+'git remote update' [-p | --prune] [group | remote]...
 
 DESCRIPTION
 -----------
index 51df99ba930c47c1163cdc3399f27d2a69c29a93..ca7c639ad30fd5682014eb984ab18d3fb0546c67 100644 (file)
@@ -1232,8 +1232,14 @@ static int update(int argc, const char **argv)
                int groups_found = 0;
                remote_group.name = argv[i];
                result = git_config(get_remote_group, &groups_found);
-               if (!groups_found && (i != 1 || strcmp(argv[1], "default")))
-                       die("No such remote group: '%s'", argv[i]);
+               if (!groups_found && (i != 1 || strcmp(argv[1], "default"))) {
+                       struct remote *remote;
+                       if (!remote_is_configured(argv[i]))
+                               die("No such remote or remote group: %s",
+                                   argv[i]);
+                       remote = remote_get(argv[i]);
+                       string_list_append(remote->name, remote_group.list);
+               }
        }
 
        if (!result && !list.nr  && argc == 2 && !strcmp(argv[1], "default"))