diff --git a/builtin/config.c b/builtin/config.c index 65e79c7673..cfd89a4186 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -923,6 +923,8 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix, if (url) ret = get_urlmatch(&location_opts, &display_opts, argv[0], url); + else if (display_opts.type == TYPE_COLOR && !strlen(argv[0]) && display_opts.default_value) + ret = get_color(&location_opts, "", display_opts.default_value); else ret = get_value(&location_opts, &display_opts, argv[0], value_pattern, get_value_flags, flags); diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 6d1015acfd..3cf5d17aba 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1083,11 +1083,22 @@ test_expect_success 'get --type=color' ' rm .git/config && git config ${mode_set} foo.color "red" && git config --get --type=color foo.color >actual.raw && + git config get --type=color foo.color >actual-subcommand.raw && + test_cmp actual.raw actual-subcommand.raw && test_decode_color actual && echo "" >expect && test_cmp expect actual ' +test_expect_success 'get --type=color with default value only' ' + git config --get-color "" "red" >actual.raw && + test_decode_color actual && + echo "" >expect && + test_cmp expect actual && + git config get --type=color --default="red" "" >actual-subcommand.raw && + test_cmp actual.raw actual-subcommand.raw +' + test_expect_success 'set --type=color' ' cat >expect <<\EOF && [foo]