Re: [PATCHv3 09/13] submodule config: keep update strategy around
- From
Stefan Beller <sbeller@google.com>
- Date
- Sep 22, 2015, 15:50 UTC
- Message-ID
- <CAGZ79kYmz9+V8CUQhr3QsRdUkzi7ofMPK=qdXkW=o-+CToU1kw@mail.gmail.com>
- In-Reply-To
- <CAPig+cRGBSYbt6FsRwNR2TYz7vD650f3=KH_c87h27SaVCUTcQ@mail.gmail.com>
On Mon, Sep 21, 2015 at 5:56 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 30 quoted lines
> On Mon, Sep 21, 2015 at 6:39 PM, Stefan Beller <sbeller@google.com> wrote:
>> We need the submodule update strategies in a later patch.
>>
>> Signed-off-by: Stefan Beller <sbeller@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?To be honest, I just copied it from above, where the url is read using the exact same workflow. In the reroll I'll fix both.
Show 13 quoted lines
>
> 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);
> }
> }