Thread (1 message) 1 message, 1 author, 2020-09-18

Re: [PATCH 1/2] config: improve error message for boolean config

From: Junio C Hamano <hidden>
Date: 2020-09-18 19:14:43
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Phillip Wood [off-list ref] 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)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help