]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: correct bad boolean env value error message
authorCalvin Wan <calvinwan@google.com>
Fri, 29 Sep 2023 21:20:50 +0000 (14:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Sep 2023 22:14:56 +0000 (15:14 -0700)
An incorrectly defined boolean environment value would result in the
following error message:

bad boolean config value '%s' for '%s'

This is a misnomer since environment value != config value. Instead of
calling git_config_bool() to parse the environment value, mimic the
functionality inside of git_config_bool() but with the correct error
message.

Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c

index 3846a37be971c92153eb1ceeb65c6e612c8e173c..7dde0aaa026b5ec118f67bee67a67b78129d73fb 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2133,7 +2133,14 @@ void git_global_config(char **user_out, char **xdg_out)
 int git_env_bool(const char *k, int def)
 {
        const char *v = getenv(k);
-       return v ? git_config_bool(k, v) : def;
+       int val;
+       if (!v)
+               return def;
+       val = git_parse_maybe_bool(v);
+       if (val < 0)
+               die(_("bad boolean environment value '%s' for '%s'"),
+                   v, k);
+       return val;
 }
 
 /*