diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2017-05-01 17:05:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-02 11:02:37 +0900 |
commit | db4eca1feaafa0669b7ba64c10314dfe8836576a (patch) | |
tree | 1bc338be729cf190a78f962a68569843c8a79544 /t | |
parent | 3b9e3c2cede15057af3ff8076c45ad5f33829436 (diff) | |
download | git-db4eca1feaafa0669b7ba64c10314dfe8836576a.tar.gz git-db4eca1feaafa0669b7ba64c10314dfe8836576a.tar.xz |
clone: handle empty config values in -c
"git clone --config" uses the following incantation to add an item to
a config file, instead of replacing an existing value:
git_config_set_multivar_gently(key, value, "^$", 0)
As long as no existing value matches the regex ^$, that works as
intended and adds to the config. When a value is empty, though, it
replaces the existing value.
Noticed while trying to set credential.helper during a clone to use a
specific helper without inheriting from ~/.gitconfig and
/etc/gitconfig. That is, I ran
git clone -c credential.helper= \
-c credential.helper=myhelper \
https://example.com/repo
intending to produce the configuration
[credential]
helper =
helper = myhelper
Without this patch, the 'helper =' line is not included and the
credential helper from /etc/gitconfig gets used.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t5611-clone-config.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh index e4850b778..39329eb7a 100755 --- a/t/t5611-clone-config.sh +++ b/t/t5611-clone-config.sh @@ -19,6 +19,14 @@ test_expect_success 'clone -c can set multi-keys' ' test_cmp expect actual ' +test_expect_success 'clone -c can set multi-keys, including some empty' ' + rm -rf child && + git clone -c credential.helper= -c credential.helper=hi . child && + printf "%s\n" "" hi >expect && + git --git-dir=child/.git config --get-all credential.helper >actual && + test_cmp expect actual +' + test_expect_success 'clone -c without a value is boolean true' ' rm -rf child && git clone -c core.foo . child && |