Re: [PATCH v7 03/10] Add colors to interactive git-clean
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 13, 2013, 05:28 UTC
- Message-ID
- <7vhai7qwhi.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CANYiYbGqZ6FiHTZgejrA3a-njffQNJyaefFmCWfycuE6PGjwbA@mail.gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 22 quoted lines
> 2013/5/13 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>:
>> Jiang Xin <worldhello.net@gmail.com> writes:
>>
>>> * color.interactive.<slot>: Use customized color for interactive
>>> git-clean output (like git add --interactive). <slot> may be
>>> prompt, header, help or error.
>>
>> This should go to the documentation (a short summary is welcome in the
>> commit messages in addition, but users won't read this...)
>>
>>> + if (!prefixcmp(var, "color.interactive.")) {
>>> + int slot = parse_clean_color_slot(var, 18);
>>
>> For readability and maintainability: please use
>> strlen("color.interactive."), not 18.
>
> Feel like conventional:
>
> git grep -C2 prefixcmp builtin/apply.c builtin/archive.c
> builtin/branch.c builtin/checkout.c
>
> But maybe 18 characters are too long. ;-)Why does it even have to know where the prefix ends or how long the prefix is?
Doesn't it suggest that perhaps the parse_clean_color_slot()'s external interface is misdesigned? In the other examples you showed, e.g.
builtin/apply.c: if (!prefixcmp(buffer, "delta ")) {
builtin/apply.c- patch_method = BINARY_DELTA_DEFLATED;
builtin/apply.c- origlen = strtoul(buffer + 6, NULL, 10);we are calling external libraries that are designed to take a pointer to a character, but the parse-clean-color-slot knows that it is fed the name of a configuration variable and it knows the shape of its input far better than a generic function like strtoul(), no?