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 f0d4d398e2
(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>
This commit is contained in:
Patrick Steinhardt
2025-06-02 08:44:42 +02:00
committed by Junio C Hamano
parent faac9d46e0
commit ddfcb9d466
4 changed files with 31 additions and 20 deletions

View File

@@ -30,7 +30,7 @@ setup_repo() {
test_repo=test test_repo=test
push_repo() { push_repo() {
test_create_repo $test_repo git init --quiet $test_repo
cd $test_repo cd $test_repo
setup_repo setup_repo

View File

@@ -48,11 +48,12 @@ commit_file () {
git commit "$@" -m "Commit $*" >/dev/null git commit "$@" -m "Commit $*" >/dev/null
} }
test_create_repo sm1 && test_expect_success 'setup submodule' '
add_file . foo >/dev/null git init sm1 &&
add_file . foo &&
head1=$(add_file sm1 foo1 foo2) head1=$(add_file sm1 foo1 foo2) &&
fullhead1=$(cd sm1; git rev-parse --verify HEAD) fullhead1=$(cd sm1 && git rev-parse --verify HEAD)
'
test_expect_success 'added submodule' ' test_expect_success 'added submodule' '
git add sm1 && git add sm1 &&
@@ -235,10 +236,13 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
test_cmp expected actual test_cmp expected actual
' '
rm -f sm1 && test_expect_success 'setup submodule anew' '
test_create_repo sm1 && rm -f sm1 &&
head6=$(add_file sm1 foo6 foo7) git init sm1 &&
fullhead6=$(cd sm1; git rev-parse --verify HEAD) head6=$(add_file sm1 foo6 foo7) &&
fullhead6=$(cd sm1 && git rev-parse --verify HEAD)
'
test_expect_success 'nonexistent commit' ' test_expect_success 'nonexistent commit' '
git diff-index -p --submodule=log HEAD >actual && git diff-index -p --submodule=log HEAD >actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&

View File

@@ -363,9 +363,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
diff_cmp expected actual diff_cmp expected actual
' '
rm -f sm1 && test_expect_success 'setup' '
test_create_repo sm1 && rm -f sm1 &&
head6=$(add_file sm1 foo6 foo7) git init sm1 &&
head6=$(add_file sm1 foo6 foo7)
'
test_expect_success 'nonexistent commit' ' test_expect_success 'nonexistent commit' '
git diff-index -p --submodule=diff HEAD >actual && git diff-index -p --submodule=diff HEAD >actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&

View File

@@ -38,10 +38,11 @@ commit_file () {
git commit "$@" -m "Commit $*" >/dev/null git commit "$@" -m "Commit $*" >/dev/null
} }
test_create_repo sm1 && test_expect_success 'setup submodule' '
add_file . foo >/dev/null git init sm1 &&
add_file . foo &&
head1=$(add_file sm1 foo1 foo2) head1=$(add_file sm1 foo1 foo2)
'
test_expect_success 'added submodule' " test_expect_success 'added submodule' "
git add sm1 && git add sm1 &&
@@ -214,9 +215,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
test_cmp expected actual test_cmp expected actual
" "
rm -f sm1 && test_expect_success 'setup submodule' '
test_create_repo sm1 && rm -f sm1 &&
head6=$(add_file sm1 foo6 foo7) git init sm1 &&
head6=$(add_file sm1 foo6 foo7)
'
test_expect_success 'nonexistent commit' " test_expect_success 'nonexistent commit' "
git submodule summary >actual && git submodule summary >actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&