Re: [PATCH v2 11/13] color: add color_parse_gently()
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Feb 17, 2026, 09:05 UTC
- Message-ID
- <aZQvT_fTlUIJd1DM@pks.im>
- In-Reply-To
- <ddf6131ac9283bfbf4ec9ec000606765d887e6ec.1771026918.git.gitgitgadget@gmail.com>
On Fri, Feb 13, 2026 at 11:55:16PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 22 quoted lines
> 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.
So should we rename the parameter to `quiet`?
Show 15 quoted lines
>
> +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