Re: [PATCH v2 06/13] config: format bools or ints gently
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Feb 23, 2026, 03:25 UTC
- Message-ID
- <a72fd162-d904-496b-90e7-34c78299c356@gmail.com>
- In-Reply-To
- <aZQvRH4vPkPYHyg9@pks.im>
On 2/17/26 4:05 AM, Patrick Steinhardt wrote:
Show 23 quoted lines
> On Fri, Feb 13, 2026 at 11:55:11PM +0000, Derrick Stolee via GitGitGadget wrote:
>> diff --git a/builtin/config.c b/builtin/config.c
>> index 2c169fc126..2c93e1725b 100644
>> --- a/builtin/config.c
>> +++ b/builtin/config.c
>> @@ -274,6 +274,34 @@ static int format_config_bool(struct strbuf *buf,
>> return 0;
>> }
>>
>> +static int format_config_bool_or_int(struct strbuf *buf,
>> + const char *key_,
>> + const char *value_,
>> + const struct key_value_info *kvi,
>> + int gently)
>> +{
>> + int v, is_bool = 0;
>> +
>> + if (gently) {
>> + v = git_parse_maybe_bool_text(value_);
>
> This function also returns `1` in case `!value`. Is this intended? I
> guess so due to our implicit bool thingy, and `git_config_bool_or_int()`
> seems to behave the same.Do you mean in the case of a NULL value?
Based on the rules for iterating through config values, deep down in get_value() the value parameter sent to the function is never NULL. It may be an empty string, but never NULL.
Thanks, -Stolee