From 386e7a9d307938eb9827c1c65ef75dc38daf0b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 30 Jun 2022 12:18:34 +0200 Subject: [PATCH 1/3] tests: add missing double quotes to included library paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix inclusion errors which would occur if the $TEST_DIRECTORY had $IFS whitespace in it. See d42bab442d7 (core.fsyncmethod: tests for batch mode, 2022-04-04) and a242c150ebb (vimdiff: integrate layout tests in the unit tests framework ('t' folder), 2022-03-30) for the two relevant commits. Both were first released with v2.37.0-rc0 (and were also part of v2.37.0). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t3700-add.sh | 2 +- t/t3903-stash.sh | 2 +- t/t7609-mergetool--lib.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 8979c8a5f0..8689b48589 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -8,7 +8,7 @@ test_description='Test of git add, including the -- option.' TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh -. $TEST_DIRECTORY/lib-unique-files.sh +. "$TEST_DIRECTORY"/lib-unique-files.sh # Test the file mode "$1" of the file "$2" in the index. test_mode_in_index () { diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 20e9488196..2a4c3fd61c 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh -. $TEST_DIRECTORY/lib-unique-files.sh +. "$TEST_DIRECTORY"/lib-unique-files.sh test_expect_success 'usage on cmd and subcommand invalid option' ' test_expect_code 129 git stash --invalid-option 2>usage && diff --git a/t/t7609-mergetool--lib.sh b/t/t7609-mergetool--lib.sh index d848fe6442..330d6d603d 100755 --- a/t/t7609-mergetool--lib.sh +++ b/t/t7609-mergetool--lib.sh @@ -7,7 +7,7 @@ Testing basic merge tools options' . ./test-lib.sh test_expect_success 'mergetool --tool=vimdiff creates the expected layout' ' - . $GIT_BUILD_DIR/mergetools/vimdiff && + . "$GIT_BUILD_DIR"/mergetools/vimdiff && run_unit_tests ' From 361fa321ec25cbbdf21df9309a82e5280c19fa02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 30 Jun 2022 12:18:35 +0200 Subject: [PATCH 2/3] test-lib.sh: fix prepend_var() quoting issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a quoting issue in the function introduced in b9638d7286f (test-lib: make $GIT_BUILD_DIR an absolute path, 2022-02-27), running the test suite where the git checkout was on a path with e.g. a space in it would fail. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/test-lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 736c6447ec..76bce78a1b 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -57,14 +57,14 @@ fi # # prepend_var VAR : VALUE prepend_var () { - eval "$1=$3\${$1:+${3:+$2}\$$1}" + eval "$1=\"$3\${$1:+${3:+$2}\$$1}\"" } # If [AL]SAN is in effect we want to abort so that we notice # problems. The GIT_SAN_OPTIONS variable can be used to set common # defaults shared between [AL]SAN_OPTIONS. prepend_var GIT_SAN_OPTIONS : abort_on_error=1 -prepend_var GIT_SAN_OPTIONS : strip_path_prefix=\"$GIT_BUILD_DIR/\" +prepend_var GIT_SAN_OPTIONS : strip_path_prefix="$GIT_BUILD_DIR/" # If we were built with ASAN, it may complain about leaks # of program-lifetime variables. Disable it by default to lower From eb1cd60290d3898ef3c3293a11400f9fff9376cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 30 Jun 2022 12:18:36 +0200 Subject: [PATCH 3/3] config tests: fix harmless but broken "rm -r" cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "test_when_finished" cleanup phase added in 4179b4897f2 (config: allow overriding of global and system configuration, 2021-04-19) has never worked as intended, firstly the ".config/git" is a directory, so we'd need the "-r" flag, but more importantly the $HOME variable wasn't properly quoted. We'd thus end up trying to remove the "trash" part of "trash directory", which wouldn't fail with "-f", since "rm -f" won't fail on non-existing files. It's possible that this would have caused an actual failure if someone had a $HOME with a space character in it, such that our "rm -f" would fail to remove an existing directory, but in practice that probably never happened. Let's fix both the quoting issue, and the other issue cleanup issue in 4179b4897f2, which is that we were attempting to clean up ~/.config/git, but weren't cleaing up ~/.gitconfig. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t1300-config.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/t1300-config.sh b/t/t1300-config.sh index d3d9adbb3d..c6661e61af 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -2083,12 +2083,13 @@ test_expect_success '--show-scope with --show-origin' ' ' test_expect_success 'override global and system config' ' - test_when_finished rm -f "$HOME"/.config/git && - + test_when_finished rm -f \"\$HOME\"/.gitconfig && cat >"$HOME"/.gitconfig <<-EOF && [home] config = true EOF + + test_when_finished rm -rf \"\$HOME\"/.config/git && mkdir -p "$HOME"/.config/git && cat >"$HOME"/.config/git/config <<-EOF && [xdg]