diff options
author | Taylor Blau <me@ttaylorr.com> | 2018-03-28 18:16:34 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-29 13:25:00 -0700 |
commit | 1f7fe5edf5f8e024af45f933a86790c59feaac90 (patch) | |
tree | 0641d562b778bc7f5f59fd35d9f25cdda57463dc /t/t1300-repo-config.sh | |
parent | b0d4ef43494f63404d883434dc36e953e97d7e24 (diff) | |
download | git-tb/config-default.tar.gz |
builtin/config: introduce `color` type specifiertb/config-default
As of this commit, the canonical way to retreive an ANSI-compatible
color escape sequence from a configuration file is with the
`--get-color` action.
This is to allow Git to "fall back" on a default value for the color
should the given section not exist in the specified configuration(s).
With the addition of `--default`, this is no longer needed since:
$ git config --default red --type=color core.section
will be have exactly as:
$ git config --get-color core.section red
For consistency, let's introduce `--color` and encourage `--type=color`,
`--default` together over `--get-color` alone.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1300-repo-config.sh')
-rwxr-xr-x | t/t1300-repo-config.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 12dc94bd20..12e852a1d6 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -931,6 +931,36 @@ test_expect_success 'get --expiry-date' ' test_must_fail git config --expiry-date date.invalid1 ' +test_expect_success 'get --type=color' ' + rm .git/config && + git config foo.color "red" && + git config --get --type=color foo.color >actual.raw && + test_decode_color <actual.raw >actual && + echo "<RED>" >expect && + test_cmp expect actual +' + +cat >expect << EOF +[foo] + color = red +EOF + +test_expect_success 'set --type=color' ' + rm .git/config && + git config --type=color foo.color "red" && + test_cmp expect .git/config +' + +test_expect_success 'get --type=color barfs on non-color' ' + echo "[foo]bar=not-a-color" >.git/config && + test_must_fail git config --get --type=color foo.bar +' + +test_expect_success 'set --type=color barfs on non-color' ' + test_must_fail git config --type=color foo.color "not-a-color" 2>error && + test_i18ngrep "cannot parse color" error +' + cat > expect << EOF [quote] leading = " test" |