On Mon, Sep 21, 2015 at 6:39 PM, Stefan Beller <sbel...@google.com> wrote:
> We need the submodule update strategies in a later patch.
>
> Signed-off-by: Stefan Beller <sbel...@google.com>
> ---
> diff --git a/submodule-config.c b/submodule-config.c
> @@ -326,6 +327,21 @@ static int parse_config(const char *var, const char 
> *value, void *data)
>                 free((void *) submodule->url);
>                 strbuf_addstr(&url, value);
>                 submodule->url = strbuf_detach(&url, NULL);
> +       } else if (!strcmp(item.buf, "update")) {
> +               struct strbuf update = STRBUF_INIT;
> +               if (!value) {
> +                       ret = config_error_nonbool(var);
> +                       goto release_return;
> +               }
> +               if (!me->overwrite && submodule->update != NULL) {
> +                       warn_multiple_config(me->commit_sha1, submodule->name,
> +                                       "update");
> +                       goto release_return;
> +               }
> +
> +               free((void *) submodule->update);
> +               strbuf_addstr(&update, value);
> +               submodule->update = strbuf_detach(&update, NULL);
>         }
>
>  release_return:

Why the complicated logic flow? Also, why is strbuf 'update' needed?

I'd have expected to see something simpler, such as:

    } else if (!strcmp(item.buf, "update")) {
        if (!value)
            ret = config_error_nonbool(var);
        else if (!me->overwrite && ...)
            warn_multiple_config(...);
        else {
            free((void *)submodule->update);
            submodule->update = xstrdup(value);
        }
    }
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to