config: correct bad boolean env value error message

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>

Calvin Wan committed Sep 29, 2023 at 14:20 UTC e16be13cfaf1102340c7816d14cec2009a864faf
1 file changed +8 -1
config.c
+8 -1
@@ -2133,7 +2133,14 @@ void git_global_config(char **user_out, char **xdg_out)
2133 int git_env_bool(const char *k, int def)
2134 {
2135 const char *v = getenv(k);
2136 - return v ? git_config_bool(k, v) : def;
2136 + int val;
2137 + if (!v)
2138 + return def;
2139 + val = git_parse_maybe_bool(v);
2140 + if (val < 0)
2141 + die(_("bad boolean environment value '%s' for '%s'"),
2142 + v, k);
2143 + return val;
2144 }
2145
2146 /*