Skip to content

Commit

Permalink
git remote update: Fallback to remote if group does not exist
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Finn Arne Gangstad authored and Junio C Hamano committed Apr 8, 2009
1 parent 9a23ba3 commit b344e16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Documentation/git-remote.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand Down
10 changes: 8 additions & 2 deletions builtin-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit b344e16

Please sign in to comment.