Skip to content

Commit bed5d42

Browse files
Finn Arne Gangstadgitster
authored andcommitted
git remote update: Report error for non-existing groups
Previosly, git remote update <non-existing-group> would just silently fail and do nothing. Now it will report an error saying that the group does not exist. Signed-off-by: Finn Arne Gangstad <finnag@pvv.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent efa5480 commit bed5d42

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

builtin-remote.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,16 +1188,18 @@ struct remote_group {
11881188
struct string_list *list;
11891189
} remote_group;
11901190

1191-
static int get_remote_group(const char *key, const char *value, void *cb)
1191+
static int get_remote_group(const char *key, const char *value, void *num_hits)
11921192
{
11931193
if (!prefixcmp(key, "remotes.") &&
11941194
!strcmp(key + 8, remote_group.name)) {
11951195
/* split list by white space */
11961196
int space = strcspn(value, " \t\n");
11971197
while (*value) {
1198-
if (space > 1)
1198+
if (space > 1) {
11991199
string_list_append(xstrndup(value, space),
12001200
remote_group.list);
1201+
++*((int *)num_hits);
1202+
}
12011203
value += space + (value[space] != '\0');
12021204
space = strcspn(value, " \t\n");
12031205
}
@@ -1227,8 +1229,11 @@ static int update(int argc, const char **argv)
12271229

12281230
remote_group.list = &list;
12291231
for (i = 1; i < argc; i++) {
1232+
int groups_found = 0;
12301233
remote_group.name = argv[i];
1231-
result = git_config(get_remote_group, NULL);
1234+
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]);
12321237
}
12331238

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

0 commit comments

Comments
 (0)