]> Kevux Git Server - rit/commitdiff
tests: don't assume a .git/info for .git/info/exclude
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 3 Jun 2022 11:15:08 +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/exclude 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" and "git init".

In the case of ".git/modules/sub1/info" we deviate from the
established pattern in this and preceding commits of passing a
"--template=" and doing a "mkdir .git/info".

In that case "git checkout" will run the "submodule--helper clone",
and both e.g. "git submodule update --init" and "git checkout" do not
have a way to pass down options to the eventual "git init" or "git
clone". Let's instead assume that the submodule was populated with our
default templates, remove them, and then run the "mkdir".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-submodule-update.sh
t/t0008-ignores.sh
t/t3426-rebase-submodule.sh
t/t7063-status-untracked-cache.sh

index f7c7df0..03e0abb 100644 (file)
@@ -207,7 +207,7 @@ prolog () {
 # should be updated to an existing commit.
 reset_work_tree_to () {
        rm -rf submodule_update &&
-       git clone submodule_update_repo submodule_update &&
+       git clone --template= submodule_update_repo submodule_update &&
        (
                cd submodule_update &&
                rm -rf sub1 &&
@@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
        '
        # ... but an ignored file is fine.
        test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" '
-               test_when_finished "rm submodule_update/.git/info/exclude" &&
+               test_when_finished "rm -rf submodule_update/.git/info" &&
                prolog &&
                reset_work_tree_to_interested no_submodule &&
                (
                        cd submodule_update &&
                        git branch -t add_sub1 origin/add_sub1 &&
                        : >sub1 &&
+                       mkdir .git/info &&
                        echo sub1 >.git/info/exclude &&
                        $command add_sub1 &&
                        test_superproject_content origin/add_sub1 &&
@@ -951,7 +952,9 @@ test_submodule_switch_recursing_with_args () {
                reset_work_tree_to_interested add_sub1 &&
                (
                        cd submodule_update &&
+                       rm -rf .git/modules/sub1/info &&
                        git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+                       mkdir .git/modules/sub1/info &&
                        echo ignored >.git/modules/sub1/info/exclude &&
                        : >sub1/ignored &&
                        $command replace_sub1_with_file &&
index c3655a0..c70d11b 100755 (executable)
@@ -3,6 +3,7 @@
 test_description=check-ignore
 
 TEST_PASSES_SANITIZE_LEAK=true
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 init_vars () {
@@ -225,6 +226,7 @@ test_expect_success 'setup' '
                !globaltwo
                globalthree
        EOF
+       mkdir .git/info &&
        cat <<-\EOF >.git/info/exclude
                per-repo
        EOF
index 0ad3a07..7a9f112 100755 (executable)
@@ -35,6 +35,7 @@ git_rebase_interactive () {
        ls -1pR * >>actual &&
        test_cmp expect actual &&
        set_fake_editor &&
+       mkdir .git/info &&
        echo "fake-editor.sh" >.git/info/exclude &&
        may_only_be_test_must_fail "$2" &&
        $2 git rebase -i "$1"
index ca90ee8..92c2730 100755 (executable)
@@ -86,7 +86,7 @@ test_expect_success 'core.untrackedCache is unset' '
 '
 
 test_expect_success 'setup' '
-       git init worktree &&
+       git init --template= worktree &&
        cd worktree &&
        mkdir done dtwo dthree &&
        touch one two three done/one dtwo/two dthree/three &&
@@ -94,6 +94,7 @@ test_expect_success 'setup' '
        test-tool chmtime =-300 done dtwo dthree &&
        test-tool chmtime =-300 . &&
        git add one two done/one &&
+       mkdir .git/info &&
        : >.git/info/exclude &&
        git update-index --untracked-cache &&
        test_oid_cache <<-EOF