t: silence output from `test_create_repo()`

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>

Patrick Steinhardt committed Jun 2, 2025 at 08:44 UTC ddfcb9d466a4f4eab6c5bd578c9b13263d4ba610
4 files changed +31 -20
t/t1007-hash-object.sh
+1 -1
@@ -30,7 +30,7 @@ setup_repo() {
30
31 test_repo=test
32 push_repo() {
33 - test_create_repo $test_repo
33 + git init --quiet $test_repo
34 cd $test_repo
35
36 setup_repo
t/t4041-diff-submodule-option.sh
+13 -9
@@ -48,11 +48,12 @@ commit_file () {
48 git commit "$@" -m "Commit $*" >/dev/null
49 }
50
51 -test_create_repo sm1 &&
52 -add_file . foo >/dev/null
53 -
54 -head1=$(add_file sm1 foo1 foo2)
55 -fullhead1=$(cd sm1; git rev-parse --verify HEAD)
51 +test_expect_success 'setup submodule' '
52 + git init sm1 &&
53 + add_file . foo &&
54 + head1=$(add_file sm1 foo1 foo2) &&
55 + fullhead1=$(cd sm1 && git rev-parse --verify HEAD)
56 +'
57
58 test_expect_success 'added submodule' '
59 git add sm1 &&
@@ -235,10 +236,13 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
236 test_cmp expected actual
237 '
238
238 -rm -f sm1 &&
239 -test_create_repo sm1 &&
240 -head6=$(add_file sm1 foo6 foo7)
241 -fullhead6=$(cd sm1; git rev-parse --verify HEAD)
239 +test_expect_success 'setup submodule anew' '
240 + rm -f sm1 &&
241 + git init sm1 &&
242 + head6=$(add_file sm1 foo6 foo7) &&
243 + fullhead6=$(cd sm1 && git rev-parse --verify HEAD)
244 +'
245 +
246 test_expect_success 'nonexistent commit' '
247 git diff-index -p --submodule=log HEAD >actual &&
248 cat >expected <<-EOF &&
t/t4060-diff-submodule-option-diff-format.sh
+6 -3
@@ -363,9 +363,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
363 diff_cmp expected actual
364 '
365
366 -rm -f sm1 &&
367 -test_create_repo sm1 &&
368 -head6=$(add_file sm1 foo6 foo7)
366 +test_expect_success 'setup' '
367 + rm -f sm1 &&
368 + git init sm1 &&
369 + head6=$(add_file sm1 foo6 foo7)
370 +'
371 +
372 test_expect_success 'nonexistent commit' '
373 git diff-index -p --submodule=diff HEAD >actual &&
374 cat >expected <<-EOF &&
t/t7401-submodule-summary.sh
+11 -7
@@ -38,10 +38,11 @@ commit_file () {
38 git commit "$@" -m "Commit $*" >/dev/null
39 }
40
41 -test_create_repo sm1 &&
42 -add_file . foo >/dev/null
43 -
44 -head1=$(add_file sm1 foo1 foo2)
41 +test_expect_success 'setup submodule' '
42 + git init sm1 &&
43 + add_file . foo &&
44 + head1=$(add_file sm1 foo1 foo2)
45 +'
46
47 test_expect_success 'added submodule' "
48 git add sm1 &&
@@ -214,9 +215,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
215 test_cmp expected actual
216 "
217
217 -rm -f sm1 &&
218 -test_create_repo sm1 &&
219 -head6=$(add_file sm1 foo6 foo7)
218 +test_expect_success 'setup submodule' '
219 + rm -f sm1 &&
220 + git init sm1 &&
221 + head6=$(add_file sm1 foo6 foo7)
222 +'
223 +
224 test_expect_success 'nonexistent commit' "
225 git submodule summary >actual &&
226 cat >expected <<-EOF &&