Re: [PATCH 1/3] Move remote parsing into a library file out of builtin-push.
- From
Junio C Hamano <junkio@cox.net>
- Date
- May 12, 2007, 19:27 UTC
- Message-ID
- <7vhcqhyh8m.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.64.0705121144130.18541@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
Show 30 quoted lines
> +static int handle_config(const char *key, const char *value)
> +{
> + const char *name;
> + const char *subkey;
> + struct remote *remote;
> + if (!prefixcmp(key, "branch.") && current_branch &&
> + !strncmp(key + 7, current_branch, current_branch_len) &&
> + !strcmp(key + 7 + current_branch_len, ".remote")) {
> + free(default_remote_name);
> + default_remote_name = xstrdup(value);
> + }
> + if (prefixcmp(key, "remote."))
> + return 0;
> + name = key + 7;
> + subkey = strrchr(name, '.');
> + if (!subkey)
> + return error("Config with no key for remote %s", name);
> + remote = make_remote(name, subkey - name);
> + if (!strcmp(subkey, ".url")) {
> + add_uri(remote, xstrdup(value));
> + } else if (!strcmp(subkey, ".push")) {
> + add_push_refspec(remote, xstrdup(value));
> + } else if (!strcmp(subkey, ".receivepack")) {
> + if (!remote->receivepack)
> + remote->receivepack = xstrdup(value);
> + else
> + error("more than one receivepack given, using the first");
> + }
> + return 0;
> +}You forgot to update this part? With your comments on not erroring out, which made sense to me, how about this?
diff --git a/remote.c b/remote.c index dbcc74e..b032e81 100644 --- a/remote.c +++ b/remote.c @@ -150,7 +150,26 @@ static int handle_config(const char *key, const char *value) subkey = strrchr(name, '.'); if (!subkey) return error("Config with no key for remote %s", name); + if (*subkey == '/') { + warning("Config remote shorthand cannot begin with '/': %s", name); + return 0; + } remote = make_remote(name, subkey - name); + if (!value) { + /* if we ever have a boolean variable, e.g. "remote.*.disabled" + * [remote "frotz"] + * disabled + * is a valid way to set it to true; we get NULL in value so + * we need to handle it here. + * + * if (!strcmp(subkey, ".disabled")) { + * val = git_config_bool(key, value); + * return 0; + * } else + * + */ + return 0; /* ignore unknown booleans */ + } if (!strcmp(subkey, ".url")) { add_uri(remote, xstrdup(value)); } else if (!strcmp(subkey, ".push")) {