]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: don't assume a .git/info for .git/info/grafts
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 3 Jun 2022 11:15:05 +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/grafts to explicitly create
the directory.

Do this using the new "TEST_CREATE_REPO_NO_TEMPLATE" facility, and use
"mkdir" instead of "mkdir -p" to assert that we don't have the
.git/info already. An exception to this is the "with grafts" test in
"t6001-rev-list-graft.sh". There we're modifying our ".git" state in a
for-loop, in lieu of refactoring that more extensively let's use
"mkdir -p" there.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/annotate-tests.sh
t/t2400-worktree-add.sh
t/t5318-commit-graph.sh
t/t6001-rev-list-graft.sh
t/t6101-rev-parse-parents.sh
t/t8001-annotate.sh
t/t8002-blame.sh
t/t8012-blame-colors.sh

index 09e86f9ba0804f70d6561b5bda03d69535f11dcf..71f391fcaf17baab59f64253444e5c1d56ad66ef 100644 (file)
@@ -149,7 +149,7 @@ test_expect_success 'blame evil merge' '
 
 test_expect_success 'blame huge graft' '
        test_when_finished "git checkout branch2" &&
-       test_when_finished "rm -f .git/info/grafts" &&
+       test_when_finished "rm -rf .git/info" &&
        graft= &&
        for i in 0 1 2
        do
@@ -164,6 +164,7 @@ test_expect_success 'blame huge graft' '
                        graft="$graft$commit " || return 1
                done
        done &&
+       mkdir .git/info &&
        printf "%s " $graft >.git/info/grafts &&
        check_count -h 00 01 1 10 1
 '
index 2f564d533d05965fff88f51bc0f1280abae43518..f3242fef6b65772ea973a1906210950cc0411f73 100755 (executable)
@@ -5,6 +5,7 @@ test_description='test git worktree add'
 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-rebase.sh
@@ -229,6 +230,7 @@ test_expect_success 'checkout with grafts' '
        SHA1=$(git rev-parse HEAD) &&
        test_commit def &&
        test_commit xyz &&
+       mkdir .git/info &&
        echo "$(git rev-parse HEAD) $SHA1" >.git/info/grafts &&
        cat >expected <<-\EOF &&
        xyz
@@ -559,6 +561,8 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
 '
 
 post_checkout_hook () {
+       test_when_finished "rm -rf .git/hooks" &&
+       mkdir .git/hooks &&
        test_hook -C "$1" post-checkout <<-\EOF
        {
                echo $*
index fbf0d64578cde0544251020cf0df5ea6b90c4a2e..be0b5641ffc39c65a3f790ed8edda2e227201540 100755 (executable)
@@ -361,13 +361,14 @@ test_expect_success 'replace-objects invalidates commit-graph' '
 test_expect_success 'commit grafts invalidate commit-graph' '
        cd "$TRASH_DIRECTORY" &&
        test_when_finished rm -rf graft &&
-       git clone full graft &&
+       git clone --template= full graft &&
        (
                cd graft &&
                git commit-graph write --reachable &&
                test_path_is_file .git/objects/info/commit-graph &&
                H1=$(git rev-parse --verify HEAD~1) &&
                H3=$(git rev-parse --verify HEAD~3) &&
+               mkdir .git/info &&
                echo "$H1 $H3" >.git/info/grafts &&
                git -c core.commitGraph=false log >expect &&
                git -c core.commitGraph=true log >actual &&
index 7294147334a92e6be082ad57177adb6e0857facc..16635ecc33e5e67ab56985a5e4a071492ed22cc9 100755 (executable)
@@ -99,6 +99,7 @@ do
        "
 
        test_expect_success 'with grafts' "
+               mkdir -p .git/info &&
                echo '$B0 $A2' >.git/info/grafts &&
                check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
        "
index c571fa517978818703e29c72e36faf52643a8ee5..5f55ab98d352fcb24df355e0976586ed848347c1 100755 (executable)
@@ -8,6 +8,7 @@ test_description='Test git rev-parse with different parent options'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 test_cmp_rev_output () {
@@ -25,6 +26,7 @@ test_expect_success 'setup' '
        git merge -m next --allow-unrelated-histories start2 &&
        test_commit final &&
 
+       mkdir .git/info &&
        test_seq 40 |
        while read i
        do
index a536a621b24a4ee0a010fd5a3e565d2711d67806..d7167f55397f57f35a75eccff662c13b4f712ec8 100755 (executable)
@@ -4,6 +4,7 @@ test_description='git annotate'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 PROG='git annotate'
index ee4fdd8f18d572f82392b6ed2e4b4da9837b63b5..0147de304b4d104cc7f05ea1f8d68f1a07ceb80d 100755 (executable)
@@ -4,6 +4,7 @@ test_description='git blame'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 PROG='git blame -c'
index 90c75dbb283fce796847f51546a04691e0521de8..c3a5f6d01ffe5cff12b868e7cbe5a09dacbef011 100755 (executable)
@@ -4,6 +4,7 @@ test_description='colored git blame'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 PROG='git blame -c'