summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Patrick Steinhardt <ps@pks.im>2021-01-12 13:27:01 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-01-15 13:03:18 -0800
commit1ff21c05ba99ed2d0ade8318e3cb0c1a3f8d4b80 (patch)
tree5a5c333541cec7abf57326559fc958a556dadc7b /t
parentconfig: parse more robust format in GIT_CONFIG_PARAMETERS (diff)
downloadtgif-1ff21c05ba99ed2d0ade8318e3cb0c1a3f8d4b80.tar.xz
config: store "git -c" variables using more robust format
The previous commit added a new format for $GIT_CONFIG_PARAMETERS which is able to robustly handle subsections with "=" in them. Let's start writing the new format. Unfortunately, this does much less than you'd hope, because "git -c" itself has the same ambiguity problem! But it's still worth doing: - we've now pushed the problem from the inter-process communication into the "-c" command-line parser. This would free us up to later add an unambiguous format there (e.g., separate arguments like "git --config key value", etc). - for --config-env, the parser already disallows "=" in the environment variable name. So: git --config-env section.with=equals.key=ENVVAR will robustly set section.with=equals.key to the contents of $ENVVAR. The new test shows the improvement for --config-env. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1300-config.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index efdf2bf997..cc68b42b97 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1416,6 +1416,14 @@ test_expect_success 'git -c and --config-env override each other' '
test_cmp expect actual
'
+test_expect_success '--config-env handles keys with equals' '
+ echo value=with=equals >expect &&
+ ENVVAR=value=with=equals git \
+ --config-env=section.subsection=with=equals.key=ENVVAR \
+ config section.subsection=with=equals.key >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'git config --edit works' '
git config -f tmp test.value no &&
echo test.value=yes >expect &&