Skip to content

Commit b344e16

Browse files
Finn Arne Gangstadgitster
authored andcommitted
git remote update: Fallback to remote if group does not exist
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>
1 parent 9a23ba3 commit b344e16

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Documentation/git-remote.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SYNOPSIS
1616
'git remote set-head' <name> [-a | -d | <branch>]
1717
'git remote show' [-n] <name>
1818
'git remote prune' [-n | --dry-run] <name>
19-
'git remote update' [-p | --prune] [group]
19+
'git remote update' [-p | --prune] [group | remote]...
2020

2121
DESCRIPTION
2222
-----------

builtin-remote.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,14 @@ static int update(int argc, const char **argv)
12321232
int groups_found = 0;
12331233
remote_group.name = argv[i];
12341234
result = git_config(get_remote_group, &groups_found);
1235-
if (!groups_found && (i != 1 || strcmp(argv[1], "default")))
1236-
die("No such remote group: '%s'", argv[i]);
1235+
if (!groups_found && (i != 1 || strcmp(argv[1], "default"))) {
1236+
struct remote *remote;
1237+
if (!remote_is_configured(argv[i]))
1238+
die("No such remote or remote group: %s",
1239+
argv[i]);
1240+
remote = remote_get(argv[i]);
1241+
string_list_append(remote->name, remote_group.list);
1242+
}
12371243
}
12381244

12391245
if (!result && !list.nr && argc == 2 && !strcmp(argv[1], "default"))

0 commit comments

Comments
 (0)