Skip to content

Commit

Permalink
config: correct bad boolean env value error message
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
calvin-wan-google authored and gitster committed Sep 29, 2023
1 parent afd2a1d commit e16be13
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit e16be13

Please sign in to comment.