summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFinn Arne Gangstad <finnag@pvv.org>2009-04-06 13:41:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-04-08 04:51:19 (GMT)
commitbed5d42163ec2e2ddde3b1d78d303a4fb39bc0d0 (patch)
treed72f9ae9cc53416dc5d32e4ea9eb6c6d6708ce66
parentefa54803cb1dc15923799f94abf82cb0433c2b9b (diff)
downloadgit-bed5d42163ec2e2ddde3b1d78d303a4fb39bc0d0.zip
git-bed5d42163ec2e2ddde3b1d78d303a4fb39bc0d0.tar.gz
git-bed5d42163ec2e2ddde3b1d78d303a4fb39bc0d0.tar.bz2
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>
-rw-r--r--builtin-remote.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin-remote.c b/builtin-remote.c
index 3146eb4..51df99b 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -1188,16 +1188,18 @@ struct remote_group {
struct string_list *list;
} remote_group;
-static int get_remote_group(const char *key, const char *value, void *cb)
+static int get_remote_group(const char *key, const char *value, void *num_hits)
{
if (!prefixcmp(key, "remotes.") &&
!strcmp(key + 8, remote_group.name)) {
/* split list by white space */
int space = strcspn(value, " \t\n");
while (*value) {
- if (space > 1)
+ if (space > 1) {
string_list_append(xstrndup(value, space),
remote_group.list);
+ ++*((int *)num_hits);
+ }
value += space + (value[space] != '\0');
space = strcspn(value, " \t\n");
}
@@ -1227,8 +1229,11 @@ static int update(int argc, const char **argv)
remote_group.list = &list;
for (i = 1; i < argc; i++) {
+ int groups_found = 0;
remote_group.name = argv[i];
- result = git_config(get_remote_group, NULL);
+ 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 (!result && !list.nr && argc == 2 && !strcmp(argv[1], "default"))