]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: silence output from `test_create_repo()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 2 Jun 2025 06:44:42 +0000 (08:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Jun 2025 14:51:42 +0000 (07:51 -0700)
There are a couple users of `test_create_repo()` that use this function
outside of any test case. This function is nowadays only a thin wrapper
around `git init`, which by default prints a message to stdout that the
repository has been initialized. The resulting output may thus confuse
TAP parsers.

Refactor these users to instead create the repository in a "setup" test
case so that we don't explicitly have to silence them. There's one
exception in t1007: we use `push_repo()` and its `pop_repo()` equivalent
multiple times, so to reduce the noise introduced by this patch we
instead silence this invocation.

While at it, convert callsites to use git-init(1) directly as the
`test_create_repo()` function has been deprecated in f0d4d398e28
(test-lib: split up and deprecate test_create_repo(), 2021-05-10).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1007-hash-object.sh
t/t4041-diff-submodule-option.sh
t/t4060-diff-submodule-option-diff-format.sh
t/t7401-submodule-summary.sh

index b3cf53ff8c9f797d80a5c2f804df3636805c4856..2cd0be7ba76a2f77ead107f07e754ac8f88ea492 100755 (executable)
@@ -30,7 +30,7 @@ setup_repo() {
 
 test_repo=test
 push_repo() {
-       test_create_repo $test_repo
+       git init --quiet $test_repo
        cd $test_repo
 
        setup_repo
index 28f9d83d4c1c34bd9d968a18cb4ab48d6a13c1f6..4d4aa1650fe84a1db88ea9a77958aa7a2be3ca02 100755 (executable)
@@ -48,11 +48,12 @@ commit_file () {
        git commit "$@" -m "Commit $*" >/dev/null
 }
 
-test_create_repo sm1 &&
-add_file . foo >/dev/null
-
-head1=$(add_file sm1 foo1 foo2)
-fullhead1=$(cd sm1; git rev-parse --verify HEAD)
+test_expect_success 'setup submodule' '
+       git init sm1 &&
+       add_file . foo &&
+       head1=$(add_file sm1 foo1 foo2) &&
+       fullhead1=$(cd sm1 && git rev-parse --verify HEAD)
+'
 
 test_expect_success 'added submodule' '
        git add sm1 &&
@@ -235,10 +236,13 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
        test_cmp expected actual
 '
 
-rm -f sm1 &&
-test_create_repo sm1 &&
-head6=$(add_file sm1 foo6 foo7)
-fullhead6=$(cd sm1; git rev-parse --verify HEAD)
+test_expect_success 'setup submodule anew' '
+       rm -f sm1 &&
+       git init sm1 &&
+       head6=$(add_file sm1 foo6 foo7) &&
+       fullhead6=$(cd sm1 && git rev-parse --verify HEAD)
+'
+
 test_expect_success 'nonexistent commit' '
        git diff-index -p --submodule=log HEAD >actual &&
        cat >expected <<-EOF &&
index 76b83101d3b7b6b7942c30c8b1f204f201027666..dbfeb7470bcfadd37c5f9d67b5f702b1b2babb50 100755 (executable)
@@ -363,9 +363,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
        diff_cmp expected actual
 '
 
-rm -f sm1 &&
-test_create_repo sm1 &&
-head6=$(add_file sm1 foo6 foo7)
+test_expect_success 'setup' '
+       rm -f sm1 &&
+       git init sm1 &&
+       head6=$(add_file sm1 foo6 foo7)
+'
+
 test_expect_success 'nonexistent commit' '
        git diff-index -p --submodule=diff HEAD >actual &&
        cat >expected <<-EOF &&
index 9c3cc4cf4046befd76e0239c831d61b33196ee86..66c3ec2da228005824f16440f23ac7f9e4622d92 100755 (executable)
@@ -38,10 +38,11 @@ commit_file () {
        git commit "$@" -m "Commit $*" >/dev/null
 }
 
-test_create_repo sm1 &&
-add_file . foo >/dev/null
-
-head1=$(add_file sm1 foo1 foo2)
+test_expect_success 'setup submodule' '
+       git init sm1 &&
+       add_file . foo &&
+       head1=$(add_file sm1 foo1 foo2)
+'
 
 test_expect_success 'added submodule' "
        git add sm1 &&
@@ -214,9 +215,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
        test_cmp expected actual
 "
 
-rm -f sm1 &&
-test_create_repo sm1 &&
-head6=$(add_file sm1 foo6 foo7)
+test_expect_success 'setup submodule' '
+       rm -f sm1 &&
+       git init sm1 &&
+       head6=$(add_file sm1 foo6 foo7)
+'
+
 test_expect_success 'nonexistent commit' "
        git submodule summary >actual &&
        cat >expected <<-EOF &&