Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-11-26 01:12:53 +0300
committerJunio C Hamano <gitster@pobox.com>2020-11-26 01:43:48 +0300
commitfda43942d7b78d2c529a40e5e38fc34034d929cb (patch)
tree6f602c1edc3d8e75daa87b4d8ae561c99b3b99c9 /t/t1300-config.sh
parentd15671943e763902c7a9c070a988f3b0489f11f7 (diff)
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/t1300-config.sh')
-rwxr-xr-xt/t1300-config.sh24
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