Re: [PATCHv3 09/13] submodule config: keep update strategy around

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 21, 2015 at 5:56 PM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> On Mon, Sep 21, 2015 at 6:39 PM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
>> We need the submodule update strategies in a later patch.
>>
>> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
>> ---
>> 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.

>
> 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]