Re: [PATCH 1/2] config: improve error message for boolean config
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 18, 2020, 19:14 UTC
- Message-ID
- <xmqqpn6ilwwx.fsf@gitster.c.googlers.com>
- In-Reply-To
- <15b794ad-6eae-6de1-3328-9b814e8e2605@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> This patch improves things for boolean config keys but > git_config_bool_or_int() is used by status.submoduleSummary, merge.log > and commit.verbose which can be either a number or a boolean (where a > boolean generally means use a default number).
Excellent point. The rephrasing done by the patch as-is will be a regression.
> It would be a more > invasive change but I wonder if it would be better for > git_config_bool() to have it's own error message rather sharing it > with git_config_bool_or_int().
You'd probably need a variant of die_bad_numer(), with an untested patch like below.
config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/config.c b/config.c index 8db9c77098..801d944d2b 100644 --- a/config.c +++ b/config.c @@ -1097,7 +1097,10 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool) return v; } *is_bool = 0; - return git_config_int(name, value); + + if (!git_parse_int(value, &v)) + die_bad_number_or_bool(name, value); + return v; } int git_config_bool(const char *name, const char *value)