@matheusbsbs / matheus-bagliano / commits / bed5d42163
Fork 0

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>

Finn Arne Gangstad committed Apr 6, 2009 at 15:41 UTC bed5d42163ec2e2ddde3b1d78d303a4fb39bc0d0
1 file changed +8 -3
builtin-remote.c
+8 -3
@@ -1188,16 +1188,18 @@ struct remote_group {
1188 struct string_list *list;
1189 } remote_group;
1190
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)
1192 {
1193 if (!prefixcmp(key, "remotes.") &&
1194 !strcmp(key + 8, remote_group.name)) {
1195 /* split list by white space */
1196 int space = strcspn(value, " \t\n");
1197 while (*value) {
1198 - if (space > 1)
1198 + if (space > 1) {
1199 string_list_append(xstrndup(value, space),
1200 remote_group.list);
1201 + ++*((int *)num_hits);
1202 + }
1203 value += space + (value[space] != '\0');
1204 space = strcspn(value, " \t\n");
1205 }
@@ -1227,8 +1229,11 @@ static int update(int argc, const char **argv)
1229
1230 remote_group.list = &list;
1231 for (i = 1; i < argc; i++) {
1232 + int groups_found = 0;
1233 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]);
1237 }
1238
1239 if (!result && !list.nr && argc == 2 && !strcmp(argv[1], "default"))