diff options
author | Kirill A. Shutemov <kirill@shutemov.name> | 2014-02-19 00:58:55 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-02-18 16:12:14 -0800 |
commit | 3caec73b5568341c5d8f303692423a8e9fb0cb39 (patch) | |
tree | 469a2cb5f3e8bdaf95832eaf846ba76926b8751c /t | |
parent | config: change git_config_with_options() interface (diff) | |
download | tgif-3caec73b5568341c5d8f303692423a8e9fb0cb39.tar.xz |
config: teach "git config --file -" to read from the standard input
The patch extends git config --file interface to allow read config from
stdin.
Editing stdin or setting value in stdin is an error.
Include by absolute path is allowed in stdin config, but not by relative
path.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t1300-repo-config.sh | 17 | ||||
-rwxr-xr-x | t/t1305-config-include.sh | 16 |
2 files changed, 30 insertions, 3 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 967359344d..c9c426c273 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -475,15 +475,28 @@ ein.bahn=strasse EOF test_expect_success 'alternative GIT_CONFIG' ' - GIT_CONFIG=other-config git config -l >output && + GIT_CONFIG=other-config git config --list >output && test_cmp expect output ' test_expect_success 'alternative GIT_CONFIG (--file)' ' - git config --file other-config -l > output && + git config --file other-config --list >output && test_cmp expect output ' +test_expect_success 'alternative GIT_CONFIG (--file=-)' ' + git config --file - --list <other-config >output && + test_cmp expect output +' + +test_expect_success 'setting a value in stdin is an error' ' + test_must_fail git config --file - some.value foo +' + +test_expect_success 'editing stdin is an error' ' + test_must_fail git config --file - --edit +' + test_expect_success 'refer config from subdirectory' ' mkdir x && ( diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index 6edd38b39a..9ba2ba11c3 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -113,7 +113,7 @@ test_expect_success 'missing include files are ignored' ' test_expect_success 'absolute includes from command line work' ' echo "[test]one = 1" >one && echo 1 >expect && - git -c include.path="$PWD/one" config test.one >actual && + git -c include.path="$(pwd)/one" config test.one >actual && test_cmp expect actual ' @@ -138,6 +138,20 @@ test_expect_success 'relative includes from blobs fail' ' test_must_fail git config --blob=$blob test.one ' +test_expect_success 'absolute includes from stdin work' ' + echo "[test]one = 1" >one && + echo 1 >expect && + echo "[include]path=\"$(pwd)/one\"" | + git config --file - test.one >actual && + test_cmp expect actual +' + +test_expect_success 'relative includes from stdin line fail' ' + echo "[test]one = 1" >one && + echo "[include]path=one" | + test_must_fail git config --file - test.one +' + test_expect_success 'include cycles are detected' ' cat >.gitconfig <<-\EOF && [test]value = gitconfig |