Re: [PATCH v2 11/13] color: add color_parse_gently()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 17, 2026, 16:20 UTC
- Message-ID
- <xmqq5x7ve3zw.fsf@gitster.g>
- In-Reply-To
- <aZQvT_fTlUIJd1DM@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 27 quoted lines
> 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"?
Show 22 quoted lines
>
> So should we rename the parameter to `quiet`?
>
>>
>> +int color_parse_mem(const char *value, int value_len, char *dst)
>> +{
>> + return color_parse_mem_1(value, value_len, dst, 0);
>> +}
>> +
>> +int color_parse(const char *value, char *dst)
>> +{
>> + return color_parse_mem(value, strlen(value), dst);
>> +}
>> +
>> +int color_parse_gently(const char *value, char *dst)
>> +{
>> + return color_parse_mem_1(value, strlen(value), dst, 1);
>> +}
>
> And if so, this should probably be called `color_parse_quiet()`.
>
> Patrick