diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-05-08 15:59:27 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-08 15:59:27 +0900 |
commit | 00bb99c424e90b6533170a034b7cbc7ff2e85e50 (patch) | |
tree | 0a37a6794ca54fb31e3b35b0c2f31be2c542e825 /t/t1300-config.sh | |
parent | e3e042b185ce3037acb61382da53521ac0beebbf (diff) | |
parent | 63e2a0f8e9cc3d66137a72e424a8b59f1c4dbd79 (diff) | |
download | git-00bb99c424e90b6533170a034b7cbc7ff2e85e50.tar.gz |
Merge branch 'tb/config-default'
"git config --get" learned the "--default" option, to help the
calling script. Building on top of the tb/config-type topic, the
"git config" learns "--type=color" type. Taken together, you can
do things like "git config --get foo.color --default blue" and get
the ANSI color sequence for the color given to foo.color variable,
or "blue" if the variable does not exist.
* tb/config-default:
builtin/config: introduce `color` type specifier
config.c: introduce 'git_config_color' to parse ANSI colors
builtin/config: introduce `--default`
Diffstat (limited to 't/t1300-config.sh')
-rwxr-xr-x | t/t1300-config.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh index e7e6d07b3a..03c223708e 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -933,6 +933,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" |