aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/config.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 448b148563..d8b38c51d3 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -256,6 +256,24 @@ static int format_config_int64(struct strbuf *buf,
return 0;
}
+static int format_config_bool(struct strbuf *buf,
+ const char *key_,
+ const char *value_,
+ int gently)
+{
+ int v = 0;
+ if (gently) {
+ if ((v = git_parse_maybe_bool(value_)) < 0)
+ return -1;
+ } else {
+ /* may die() */
+ v = git_config_bool(key_, value_);
+ }
+
+ strbuf_addstr(buf, v ? "true" : "false");
+ return 0;
+}
+
/*
* Format the configuration key-value pair (`key_`, `value_`) and
* append it into strbuf `buf`. Returns a negative value on failure,
@@ -284,8 +302,7 @@ static int format_config(const struct config_display_options *opts,
if (opts->type == TYPE_INT)
res = format_config_int64(buf, key_, value_, kvi, gently);
else if (opts->type == TYPE_BOOL)
- strbuf_addstr(buf, git_config_bool(key_, value_) ?
- "true" : "false");
+ res = format_config_bool(buf, key_, value_, gently);
else if (opts->type == TYPE_BOOL_OR_INT) {
int is_bool, v;
v = git_config_bool_or_int(key_, value_, kvi,