diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2020-11-25 22:12:53 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-11-25 14:43:48 -0800 |
commit | fda43942d7b78d2c529a40e5e38fc34034d929cb (patch) | |
tree | 6f602c1edc3d8e75daa87b4d8ae561c99b3b99c9 /t | |
parent | t1300: add test for --replace-all with value-pattern (diff) | |
download | tgif-fda43942d7b78d2c529a40e5e38fc34034d929cb.tar.xz |
config: add --fixed-value option, un-implemented
The 'git config' builtin takes a 'value-pattern' parameter for several
actions. This can cause confusion when expecting exact value matches
instead of regex matches, especially when the input string contains
metacharacters. While callers can escape the patterns themselves, it
would be more friendly to allow an argument to disable the pattern
matching in favor of an exact string match.
Add a new '--fixed-value' option that does not currently change the
behavior. The implementation will be filled in by later changes for
each appropriate action. For now, check and test that --fixed-value
will abort the command when included with an incompatible action or
without a 'value-pattern' argument.
The name '--fixed-value' was chosen over something simpler like
'--fixed' because some commands allow regular expressions on the
key in addition to the value.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t1300-config.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh index bddf5250dc..841ed204d6 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -1970,4 +1970,28 @@ test_expect_success '--replace-all and value-pattern' ' test_cmp expect actual ' +test_expect_success 'refuse --fixed-value for incompatible actions' ' + test_when_finished rm -f config && + git config --file=config dev.null bogus && + + # These modes do not allow --fixed-value at all + test_must_fail git config --file=config --fixed-value --add dev.null bogus && + test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus && + test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus && + test_must_fail git config --file=config --fixed-value --rename-section dev null && + test_must_fail git config --file=config --fixed-value --remove-section dev && + test_must_fail git config --file=config --fixed-value --list && + test_must_fail git config --file=config --fixed-value --get-color dev.null && + test_must_fail git config --file=config --fixed-value --get-colorbool dev.null && + + # These modes complain when --fixed-value has no value-pattern + test_must_fail git config --file=config --fixed-value dev.null bogus && + test_must_fail git config --file=config --fixed-value --replace-all dev.null bogus && + test_must_fail git config --file=config --fixed-value --get dev.null && + test_must_fail git config --file=config --fixed-value --get-all dev.null && + test_must_fail git config --file=config --fixed-value --get-regexp "dev.*" && + test_must_fail git config --file=config --fixed-value --unset dev.null && + test_must_fail git config --file=config --fixed-value --unset-all dev.null +' + test_done |