From dc4179f9a76473176eb473f6f568b0006c823fba Mon Sep 17 00:00:00 2001 From: Deskin Miller Date: Mon, 22 Sep 2008 11:06:41 -0400 Subject: maint: check return of split_cmdline to avoid bad config strings As the testcase demonstrates, it's possible for split_cmdline to return -1 and deallocate any memory it's allocated, if the config string is missing an end quote. In both the cases below, which are the only calling sites, the return isn't checked, and using the pointer causes a pretty immediate segfault. Signed-off-by: Deskin Miller Acked-by: Miklos Vajna Signed-off-by: Shawn O. Pearce --- t/t1300-repo-config.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 64567fb94d..11b82f43dd 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -741,4 +741,14 @@ test_expect_success 'symlinked configuration' ' ' +test_expect_success 'check split_cmdline return' " + git config alias.split-cmdline-fix 'echo \"' && + test_must_fail git split-cmdline-fix && + echo foo > foo && + git add foo && + git commit -m 'initial commit' && + git config branch.master.mergeoptions 'echo \"' && + test_must_fail git merge master + " + test_done -- cgit v1.2.3 From 003f69b282f9cc54da771e1b3e9378aa3f5178cd Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 7 Mar 2009 12:14:04 -0500 Subject: t1300: use test_must_fail as appropriate Some of the tests checked the exit code manually, even going so far as to run git outside of the test_expect harness. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 11b82f43dd..3c06842d99 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -336,10 +336,10 @@ test_expect_success 'get bool variable with empty value' \ 'git config --bool emptyvalue.variable > output && cmp output expect' -git config > output 2>&1 - -test_expect_success 'no arguments, but no crash' \ - "test $? = 129 && grep usage output" +test_expect_success 'no arguments, but no crash' ' + test_must_fail git config >output 2>&1 && + grep usage output +' cat > .git/config << EOF [a.b] @@ -373,7 +373,7 @@ EOF test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect' test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \ - 'git config --file non-existing-config -l; test $? != 0' + 'test_must_fail git config --file non-existing-config -l' cat > other-config << EOF [ein] -- cgit v1.2.3 From bf71b4b3ee07291e97c4dabfb97e7397eec904e0 Mon Sep 17 00:00:00 2001 From: Carlos Rica Date: Tue, 17 Mar 2009 10:46:37 +0100 Subject: config: test for --replace-all with one argument and fix documentation. Option --replace-all only allows at least two arguments, so documentation was needing to be updated accordingly. A test showing that the command fails with only one parameter is also provided. Signed-off-by: Carlos Rica Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 11b82f43dd..f0a75380b3 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -118,7 +118,14 @@ EOF test_expect_success 'multiple unset is correct' 'cmp .git/config expect' -mv .git/config2 .git/config +cp .git/config2 .git/config + +test_expect_success '--replace-all missing value' ' + test_must_fail git config --replace-all beta.haha && + test_cmp .git/config2 .git/config +' + +rm .git/config2 test_expect_success '--replace-all' \ 'git config --replace-all beta.haha gamma' -- cgit v1.2.3 From 704a3143d5ba0709727430154ef3dad600aad4de Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 4 Mar 2009 22:38:24 +0100 Subject: Use prerequisite tags to skip tests that depend on symbolic links Many tests depend on that symbolic links work. This introduces a check that sets the prerequisite tag SYMLINKS if the file system supports symbolic links. Since so many tests have to check for this prerequisite, we do the check in test-lib.sh, so that we don't need to repeat the test in many scripts. To check for 'ln -s' failures, you can use a FAT partition on Linux: $ mkdosfs -C git-on-fat 1000000 $ sudo mount -o loop,uid=j6t,gid=users,shortname=winnt git-on-fat /mnt Clone git to /mnt and $ GIT_SKIP_TESTS='t0001.1[34] t0010 t1301 t403[34] t4129.[47] t5701.7 t7701.3 t9100 t9101.26 t9119 t9124.[67] t9200.10 t9600.6' \ make test (These additionally skipped tests depend on POSIX permissions that FAT on Linux does not provide.) Signed-off-by: Johannes Sixt --- t/t1300-repo-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 3c06842d99..64663e1886 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -726,7 +726,7 @@ echo >>result test_expect_success '--null --get-regexp' 'cmp result expect' -test_expect_success 'symlinked configuration' ' +test_expect_success SYMLINKS 'symlinked configuration' ' ln -s notyet myconfig && GIT_CONFIG=myconfig git config test.frotz nitfol && -- cgit v1.2.3 From 9a5abfc737b18c23d060ff3be1ee8df560b81fa5 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 24 Jul 2009 17:21:44 -0400 Subject: After renaming a section, print any trailing variable definitions Signed-off-by: Alex Vandiver Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 43ea283242..8c43dcde8a 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -459,6 +459,28 @@ EOF test_expect_success "rename succeeded" "test_cmp expect .git/config" +cat >> .git/config << EOF +[branch "vier"] z = 1 +EOF + +test_expect_success "rename a section with a var on the same line" \ + 'git config --rename-section branch.vier branch.zwei' + +cat > expect << EOF +# Hallo + #Bello +[branch "zwei"] + x = 1 +[branch "zwei"] + y = 1 +[branch "drei"] +weird +[branch "zwei"] + z = 1 +EOF + +test_expect_success "rename succeeded" "test_cmp expect .git/config" + cat >> .git/config << EOF [branch "zwei"] a = 1 [branch "vier"] EOF -- cgit v1.2.3 From ebdaae372b460ffdf5d153dcd0ac235d52b0d2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Thu, 30 Jul 2009 13:41:57 +0200 Subject: config: Keep inner whitespace verbatim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configuration values are expected to be quoted when they have leading or trailing whitespace, but inner whitespace should be kept verbatim even if the value is not quoted. This is already documented in git-config(1), but the code caused inner whitespace to be collapsed to a single space, breaking, for example, clones from a path that has two consecutive spaces in it, as future fetches would only see a single space. Reported-by: John te Bokkel Signed-off-by: Björn Steinbrink Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 43ea283242..91cbd551d8 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -733,6 +733,11 @@ echo >>result test_expect_success '--null --get-regexp' 'cmp result expect' +test_expect_success 'inner whitespace kept verbatim' ' + git config section.val "foo bar" && + test "z$(git config section.val)" = "zfoo bar" +' + test_expect_success SYMLINKS 'symlinked configuration' ' ln -s notyet myconfig && -- cgit v1.2.3 From 1349484e341a3ec2ba02a86c8fbd97ea9dc8c756 Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Wed, 30 Dec 2009 17:51:53 +0100 Subject: builtin-config: add --path option doing ~ and ~user expansion. 395de250 (Expand ~ and ~user in core.excludesfile, commit.template) introduced a C function git_config_pathname, doing ~/ and ~user/ expansion. This patch makes the feature available to scripts with 'git config --get --path'. Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 83b7294010..f89d7e9e49 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -683,6 +683,34 @@ test_expect_success 'set --bool-or-int' ' rm .git/config +cat >expect <<\EOF +[path] + home = ~/ + normal = /dev/null + trailingtilde = foo~ +EOF + +test_expect_success 'set --path' ' + git config --path path.home "~/" && + git config --path path.normal "/dev/null" && + git config --path path.trailingtilde "foo~" && + test_cmp expect .git/config' + +cat >expect < result && + git config --get --path path.normal >> result && + git config --get --path path.trailingtilde >> result && + test_cmp expect result +' + +rm .git/config + git config quote.leading " test" git config quote.ending "test " git config quote.semicolon "test;test" -- cgit v1.2.3 From 65807ee697a28cb30b8ad38ebb8b84cebd3f255d Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Tue, 26 Jan 2010 16:02:16 +0100 Subject: builtin-config: Fix crash when using "-f " from non-root dir When your current directory is not at the root of the working tree, and you use the "-f" option with a relative path, the current code tries to read from a wrong file, since argv[2] is now beyond the end of the rearranged argument list. This patch replaces the incorrect argv[2] with the variable holding the given config file name. The bug was introduced by d64ec16 (git config: reorganize to use parseopt). [jc: added test] Signed-off-by: Johan Herland Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t1300-repo-config.sh') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 43ea283242..c81ccf2e56 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -398,6 +398,17 @@ test_expect_success 'alternative GIT_CONFIG' 'cmp output expect' test_expect_success 'alternative GIT_CONFIG (--file)' \ 'git config --file other-config -l > output && cmp output expect' +test_expect_success 'refer config from subdirectory' ' + mkdir x && + ( + cd x && + echo strasse >expect + git config --get --file ../other-config ein.bahn >actual && + test_cmp expect actual + ) + +' + GIT_CONFIG=other-config git config anwohner.park ausweis cat > expect << EOF -- cgit v1.2.3