Re: [PATCH v2 11/13] color: add color_parse_gently()
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Feb 23, 2026, 02:12 UTC
- Message-ID
- <8fae2d15-cb0d-4ccb-8cd3-c4775b6666dd@gmail.com>
- In-Reply-To
- <xmqq5x7ve3zw.fsf@gitster.g>
On 2/17/26 11:20 AM, Junio C Hamano wrote:
Show 33 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
>> On Fri, Feb 13, 2026 at 11:55:16PM +0000, Derrick Stolee via GitGitGadget wrote:
>>> diff --git a/color.c b/color.c
>>> index 07ac8c9d40..ec8872d2dd 100644
>>> --- a/color.c
>>> +++ b/color.c
>>> @@ -264,7 +259,8 @@ static int color_empty(const struct color *c)
>>> return c->type <= COLOR_NORMAL;
>>> }
>>>
>>> -int color_parse_mem(const char *value, int value_len, char *dst)
>>> +static int color_parse_mem_1(const char *value, int value_len,
>>> + char *dst, int gently)
>>> {
>>> const char *ptr = value;
>>> int len = value_len;
>>> @@ -365,10 +361,25 @@ int color_parse_mem(const char *value, int value_len, char *dst)
>>> OUT(0);
>>> return 0;
>>> bad:
>>> - return error(_("invalid color value: %.*s"), value_len, value);
>>> + return gently ? -1 : error(_("invalid color value: %.*s"), value_len, value);
>>> #undef OUT
>>> }
>>
>> As far as I can see this isn't really about whether or not the function
>> should be gentle. It's rather whether or not the function should print
>> an error message when it sees an error.
>
> Do you mean that this error() call is not die(), the flag does not
> fit the usual "gently" criteria? In other words, should we make
> this call die() if we call it "gently"?This is an interesting case where the existing color parsing logic is not following the typical pattern that uses die() on a failed parse.
If we want to change the behavior to die() later, then that could be considered, though I don't want to consider the ramifications right now.
I think the easiest "local" fix is to use the 'quiet' way, though it adds some asymmetry in the config code in how it uses the 'gently' parameter. Let me give this a try in the next version so we can see how it feels.
Thanks, -Stolee