]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: don't assume a .git/info for .git/info/attributes
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 3 Jun 2022 11:15:06 +0000 (13:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Jun 2022 19:00:21 +0000 (12:00 -0700)
Change those tests that assumed that a .git/info directory would be
created for them when writing .git/info/attributes to explicitly
create the directory by setting "TEST_CREATE_REPO_NO_TEMPLATE=1"
before sourcing test-lib.sh, and using the "--template=" argument to
"git clone".

The change here in here in t7814-grep-recurse-submodules.sh would
continue "succeeding" with only the "TEST_CREATE_REPO_NO_TEMPLATE=1"
part of this change. That's because those tests use
"test_expect_failure", so they'd "pass" without this change, as
"test_expect_failure" by design isn't discerning about what failure
conditions it'll accept.

But as we're fixing these sorts of issues across the test suite let's
fix this one too. This issue was spotted with a local merge with
another topic of mine[1], which introduces a stricter alternative to
"test_expect_failure".

1. https://lore.kernel.org/git/cover-0.7-00000000000-20220318T002951Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0003-attributes.sh
t/t0028-working-tree-encoding.sh
t/t5000-tar-tree.sh
t/t5001-archive-attr.sh
t/t5002-archive-attr-pattern.sh
t/t5003-archive-zip.sh
t/t7814-grep-recurse-submodules.sh

index 143f1005179c8afb11aba90e4d279b6d288c8a48..f7ee2f2ff0e6ee3be99ecd4d545c376963653482 100755 (executable)
@@ -3,6 +3,7 @@
 test_description=gitattributes
 
 TEST_PASSES_SANITIZE_LEAK=true
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 attr_check_basic () {
@@ -284,7 +285,7 @@ test_expect_success 'using --git-dir and --work-tree' '
 '
 
 test_expect_success 'setup bare' '
-       git clone --bare . bare.git
+       git clone --template= --bare . bare.git
 '
 
 test_expect_success 'bare repository: check that .gitattribute is ignored' '
@@ -315,6 +316,7 @@ test_expect_success 'bare repository: check that --cached honors index' '
 test_expect_success 'bare repository: test info/attributes' '
        (
                cd bare.git &&
+               mkdir info &&
                (
                        echo "f test=f" &&
                        echo "a/i test=a/i"
@@ -360,6 +362,7 @@ test_expect_success SYMLINKS 'symlinks respected in core.attributesFile' '
 
 test_expect_success SYMLINKS 'symlinks respected in info/attributes' '
        test_when_finished "rm .git/info/attributes" &&
+       mkdir .git/info &&
        ln -s ../../attr .git/info/attributes &&
        attr_check file set
 '
index 82905a2156f7daad6cbdbd1ae5e54d9235f0cdbc..7140960e1a3962795abb18f9ac962c6906f50504 100755 (executable)
@@ -5,6 +5,7 @@ test_description='working-tree-encoding conversion via gitattributes'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-encoding.sh"
 
@@ -69,6 +70,7 @@ test_expect_success 'check $GIT_DIR/info/attributes support' '
        test_when_finished "rm -f test.utf32.git" &&
        test_when_finished "git reset --hard HEAD" &&
 
+       mkdir .git/info &&
        echo "*.utf32 text working-tree-encoding=utf-32" >.git/info/attributes &&
        git add test.utf32 &&
 
index 7f8d2ab0a72dac716198a424556d1e9323f2f8c3..de192b52c47421f253efa0e150e721199549f1d7 100755 (executable)
@@ -24,6 +24,7 @@ commit id embedding:
 
 '
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 SUBSTFORMAT=%H%n
@@ -143,6 +144,7 @@ test_expect_success 'populate workdir' '
 test_expect_success \
     'add ignored file' \
     'echo ignore me >a/ignored &&
+     mkdir .git/info &&
      echo ignored export-ignore >.git/info/attributes'
 
 test_expect_success 'add files to repository' '
@@ -157,7 +159,8 @@ test_expect_success 'setup export-subst' '
 '
 
 test_expect_success 'create bare clone' '
-       git clone --bare . bare.git &&
+       git clone --template= --bare . bare.git &&
+       mkdir bare.git/info &&
        cp .git/info/attributes bare.git/info/attributes
 '
 
index 712ae52299431c3d31038123a02f895708086bdd..2f6eef5e3720452df49c4810bd9f4f63dc1167fb 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='git archive attribute tests'
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 SUBSTFORMAT='%H (%h)%n'
@@ -20,6 +21,7 @@ extract_tar_to_dir () {
 
 test_expect_success 'setup' '
        echo ignored >ignored &&
+       mkdir .git/info &&
        echo ignored export-ignore >>.git/info/attributes &&
        git add ignored &&
 
@@ -46,7 +48,8 @@ test_expect_success 'setup' '
 
        git commit -m. &&
 
-       git clone --bare . bare &&
+       git clone --template= --bare . bare &&
+       mkdir bare/info &&
        cp .git/info/attributes bare/info/attributes
 '
 
index a66b5ba27e869e377a317258c03cde8953323d8f..78ab75f1bc2442144670a2df06de790ee43d82b7 100755 (executable)
@@ -3,6 +3,7 @@
 test_description='git archive attribute pattern tests'
 
 TEST_PASSES_SANITIZE_LEAK=true
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 test_expect_exists() {
@@ -15,6 +16,7 @@ test_expect_missing() {
 
 test_expect_success 'setup' '
        echo ignored >ignored &&
+       mkdir .git/info &&
        echo ignored export-ignore >>.git/info/attributes &&
        git add ignored &&
 
@@ -54,7 +56,8 @@ test_expect_success 'setup' '
 
        git commit -m. &&
 
-       git clone --bare . bare &&
+       git clone --template= --bare . bare &&
+       mkdir bare/info &&
        cp .git/info/attributes bare/info/attributes
 '
 
index d726964307ca89373eeaf206bbb2dc2d4c1c3008..a7bbfcb7f75a89853b4f19f2870dd7c37e3cb672 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='git archive --format=zip test'
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 SUBSTFORMAT=%H%n
@@ -121,6 +122,7 @@ test_expect_success 'prepare file list' '
 test_expect_success \
     'add ignored file' \
     'echo ignore me >a/ignored &&
+     mkdir .git/info &&
      echo ignored export-ignore >.git/info/attributes'
 
 test_expect_success 'add files to repository' '
@@ -139,7 +141,8 @@ test_expect_success 'setup export-subst and diff attributes' '
 '
 
 test_expect_success 'create bare clone' '
-       git clone --bare . bare.git &&
+       git clone --template= --bare . bare.git &&
+       mkdir bare.git/info &&
        cp .git/info/attributes bare.git/info/attributes &&
        # Recreate our changes to .git/config rather than just copying it, as
        # we do not want to clobber core.bare or other settings.
index a4476dc492204297d3b91b3d3d79a7769f4d38b9..3ad80526c4c426b1ebeb94ee0730ff9ec79a4ef2 100755 (executable)
@@ -6,6 +6,7 @@ This test verifies the recurse-submodules feature correctly greps across
 submodules.
 '
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
@@ -471,8 +472,10 @@ test_expect_failure 'grep --textconv: superproject .gitattributes (from index) d
 test_expect_failure 'grep --textconv: superproject .git/info/attributes does not affect submodules' '
        reset_and_clean &&
        test_config_global diff.d2x.textconv "sed -e \"s/d/x/\"" &&
-       super_attr="$(git rev-parse --git-path info/attributes)" &&
+       super_info="$(git rev-parse --git-path info)" &&
+       super_attr="$super_info/attributes" &&
        test_when_finished "rm -f \"$super_attr\"" &&
+       mkdir "$super_info" &&
        echo "a diff=d2x" >"$super_attr" &&
 
        cat >expect <<-\EOF &&
@@ -516,7 +519,8 @@ test_expect_failure 'grep --textconv correctly reads submodule .git/info/attribu
        reset_and_clean &&
        test_config_global diff.d2x.textconv "sed -e \"s/d/x/\"" &&
 
-       submodule_attr="$(git -C submodule rev-parse --path-format=absolute --git-path info/attributes)" &&
+       submodule_info="$(git -C submodule rev-parse --path-format=absolute --git-path info)" &&
+       submodule_attr="$submodule_info/attributes" &&
        test_when_finished "rm -f \"$submodule_attr\"" &&
        echo "a diff=d2x" >"$submodule_attr" &&