Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-02-18 04:21:43 +0300
committerJunio C Hamano <gitster@pobox.com>2021-02-18 04:21:43 +0300
commit483e09e810796786baf7a9139680f6d2f2470829 (patch)
tree41a503f778c0140db8dc565a94aa6f23869efad8 /config.c
parente68f62be8dd65cd181be20b414fa45126b39d481 (diff)
parentf276e2a469430999ff7e3735ea7b41508ed1abd8 (diff)
Merge branch 'ak/config-bad-bool-error'
The error message given when a configuration variable that is expected to have a boolean value has been improved. * ak/config-bad-bool-error: config: improve error message for boolean config
Diffstat (limited to 'config.c')
-rw-r--r--config.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/config.c b/config.c
index b922b4f285..f90b633dba 100644
--- a/config.c
+++ b/config.c
@@ -1180,6 +1180,20 @@ static void die_bad_number(const char *name, const char *value)
}
}
+NORETURN
+static void die_bad_bool(const char *name, const char *value)
+{
+ if (!strcmp(name, "GIT_TEST_GETTEXT_POISON"))
+ /*
+ * We explicitly *don't* use _() here since it would
+ * cause an infinite loop with _() needing to call
+ * use_gettext_poison().
+ */
+ die("bad boolean config value '%s' for '%s'", value, name);
+ else
+ die(_("bad boolean config value '%s' for '%s'"), value, name);
+}
+
int git_config_int(const char *name, const char *value)
{
int ret;
@@ -1252,8 +1266,10 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
int git_config_bool(const char *name, const char *value)
{
- int discard;
- return !!git_config_bool_or_int(name, value, &discard);
+ int v = git_parse_maybe_bool(value);
+ if (v < 0)
+ die_bad_bool(name, value);
+ return v;
}
int git_config_string(const char **dest, const char *var, const char *value)