Re: [PATCH 3/9] trailer: read and process config information
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Dec 24, 2013, 13:47 UTC
- Message-ID
- <CAP8UFD105z8YrgWPAzsaj7=Zx9x+DqfXBK1FUAmcFYY2rdzvBg@mail.gmail.com>
- In-Reply-To
- <20131224063726.19560.89108.chriscool@tuxfamily.org>
On Tue, Dec 24, 2013 at 7:37 AM, Christian Couder <chriscool@tuxfamily.org> wrote:
Show 32 quoted lines
>
> +static int git_trailer_config(const char *conf_key, const char *value, void *cb)
> +{
> + if (starts_with(conf_key, "trailer.")) {
> + const char *orig_conf_key = conf_key;
> + struct trailer_item *item;
> + struct conf_info *conf;
> + char *name;
> + enum trailer_info_type type;
> +
> + conf_key += 8;
> + if (!set_name_and_type(conf_key, ".key", TRAILER_VALUE, &name, &type) &&
> + !set_name_and_type(conf_key, ".command", TRAILER_COMMAND, &name, &type) &&
> + !set_name_and_type(conf_key, ".where", TRAILER_WHERE, &name, &type) &&
> + !set_name_and_type(conf_key, ".ifexist", TRAILER_IF_EXIST, &name, &type) &&
> + !set_name_and_type(conf_key, ".ifmissing", TRAILER_IF_MISSING, &name, &type))
> + return 0;
> +
> + item = get_conf_item(name);
> + conf = item->conf;
> +
> + if (type == TRAILER_VALUE) {
> + if (conf->key)
> + warning(_("more than one %s"), orig_conf_key);
> + conf->key = xstrdup(value);
> + } else if (type == TRAILER_COMMAND) {
> + if (conf->command)
> + warning(_("more than one %s"), orig_conf_key);
> + conf->command = xstrdup(value);
> + } else if (type == TRAILER_WHERE) {
> + if (set_where(conf, value))
> + warning(_("unknow value '%s' for key '%s'"), value, orig_conf_key);I realize that I forgot to s/unknow/unknown/. Sorry about that. It will be in the next version.
Show 12 quoted lines
> + } else if (type == TRAILER_IF_EXIST) {
> + if (set_if_exist(conf, value))
> + warning(_("unknow value '%s' for key '%s'"), value, orig_conf_key);
> + } else if (type == TRAILER_IF_MISSING) {
> + if (set_if_missing(conf, value))
> + warning(_("unknow value '%s' for key '%s'"), value, orig_conf_key);
> + } else {
> + die("internal bug in trailer.c");
> + }
> + }
> + return 0;
> +}