return 0;
}
+static int format_config_color(struct strbuf *buf,
+ const char *key_,
+ const char *value_,
+ int gently)
+{
+ char v[COLOR_MAXLEN];
+
+ if (gently) {
+ if (color_parse_quietly(value_, v) < 0)
+ return -1;
+ } else if (git_config_color(v, key_, value_) < 0) {
+ return -1;
+ }
+
+ strbuf_addstr(buf, v);
+ return 0;
+}
+
/*
* Format the configuration key-value pair (`key_`, `value_`) and
* append it into strbuf `buf`. Returns a negative value on failure,
res = format_config_path(buf, key_, value_, gently);
else if (opts->type == TYPE_EXPIRY_DATE)
res = format_config_expiry_date(buf, key_, value_, gently);
- else if (opts->type == TYPE_COLOR) {
- char v[COLOR_MAXLEN];
- if (git_config_color(v, key_, value_) < 0)
- return -1;
- strbuf_addstr(buf, v);
- } else if (value_) {
+ else if (opts->type == TYPE_COLOR)
+ res = format_config_color(buf, key_, value_, gently);
+ else if (value_) {
strbuf_addstr(buf, value_);
} else {
/* Just show the key name; back out delimiter */
section.blue=<BLUE>
EOF
- cat >expecterr <<-EOF &&
- error: invalid color value: True
- error: invalid color value: 1M
- error: invalid color value: ~/dir
- error: invalid color value: Fri Jun 4 15:46:55 2010
- error: invalid color value: :(optional)no-such-path
- error: invalid color value: :(optional)expect
- EOF
-
git config ${mode_prefix}list --type=color >actual.raw 2>err &&
test_decode_color <actual.raw >actual &&
test_cmp expect actual &&
- test_cmp expecterr err
+ test_must_be_empty err
'
test_expect_success '--type rejects unknown specifiers' '