From: Aaron Plattner <aplattner@nvidia.com>
To: <git@vger.kernel.org>
Cc: Aaron Plattner <aplattner@nvidia.com>
Subject: [PATCH] t: use test_seq -f and pipes in a few more places
Date: Wed, 18 Feb 2026 10:10:19 -0800 [thread overview]
Message-ID: <20260218181019.1705160-1-aplattner@nvidia.com> (raw)
Several tests use a pattern that writes to a temporary file like this:
printf "do something with %d\n" $(test_seq <count>) >tmpfile &&
git do-something --stdin <tmpfile
Other tests use test_seq's -f parameter, but still write to a temporary file:
test_seq -f "do something with %d" <count> >input &&
git do-something --stdin <input
Simplify both of these patterns to
test_seq -f "do something with %d" <count> |
git do-something --stdin
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
---
Suggested by Peff and Junio in <20260114173055.GD885771@coredump.intra.peff.net>
and <xmqqcy3cf5xa.fsf@gitster.g> respectively.
t/pack-refs-tests.sh | 24 ++++++++++--------------
t/t0613-reftable-write-options.sh | 16 ++++++++--------
t/t1400-update-ref.sh | 8 ++++----
t/t1460-refs-migrate.sh | 8 ++++----
t/t5004-archive-corner-cases.sh | 3 +--
t/t5401-update-hooks.sh | 4 ++--
6 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/t/pack-refs-tests.sh b/t/pack-refs-tests.sh
index 81086c3690..2fdaccb6c7 100644
--- a/t/pack-refs-tests.sh
+++ b/t/pack-refs-tests.sh
@@ -354,8 +354,8 @@ do
# Create 14 additional references, which brings us to
# 15 together with the default branch.
- printf "create refs/heads/loose-%d HEAD\n" $(test_seq 14) >stdin &&
- git update-ref --stdin <stdin &&
+ test_seq -f "create refs/heads/loose-%d HEAD" 14 |
+ git update-ref --stdin &&
test_path_is_missing .git/packed-refs &&
git ${pack_refs} --auto --all &&
test_path_is_missing .git/packed-refs &&
@@ -379,8 +379,8 @@ do
test_line_count = 2 .git/packed-refs &&
# Create 15 loose references.
- printf "create refs/heads/loose-%d HEAD\n" $(test_seq 15) >stdin &&
- git update-ref --stdin <stdin &&
+ test_seq -f "create refs/heads/loose-%d HEAD" 15 |
+ git update-ref --stdin &&
git ${pack_refs} --auto --all &&
test_line_count = 2 .git/packed-refs &&
@@ -401,18 +401,14 @@ do
# Create 99 packed refs. This should cause the heuristic
# to require more than the minimum amount of loose refs.
- test_seq 99 |
- while read i
- do
- printf "create refs/heads/packed-%d HEAD\n" $i || return 1
- done >stdin &&
- git update-ref --stdin <stdin &&
+ test_seq -f "create refs/heads/packed-%d HEAD" 99 |
+ git update-ref --stdin &&
git ${pack_refs} --all &&
test_line_count = 101 .git/packed-refs &&
# Create 24 loose refs, which should not yet cause us to repack.
- printf "create refs/heads/loose-%d HEAD\n" $(test_seq 24) >stdin &&
- git update-ref --stdin <stdin &&
+ test_seq -f "create refs/heads/loose-%d HEAD" 24 |
+ git update-ref --stdin &&
git ${pack_refs} --auto --all &&
test_line_count = 101 .git/packed-refs &&
@@ -420,8 +416,8 @@ do
# Note that we explicitly do not check for strict
# boundaries here, as this also depends on the size of
# the object hash.
- printf "create refs/heads/addn-%d HEAD\n" $(test_seq 10) >stdin &&
- git update-ref --stdin <stdin &&
+ test_seq -f "create refs/heads/addn-%d HEAD" 10 |
+ git update-ref --stdin &&
git ${pack_refs} --auto --all &&
test_line_count = 135 .git/packed-refs
)
diff --git a/t/t0613-reftable-write-options.sh b/t/t0613-reftable-write-options.sh
index e334751759..26b716c75f 100755
--- a/t/t0613-reftable-write-options.sh
+++ b/t/t0613-reftable-write-options.sh
@@ -68,8 +68,8 @@ test_expect_success 'many refs results in multiple blocks' '
(
cd repo &&
test_commit initial &&
- test_seq -f "update refs/heads/branch-%d HEAD" 200 >input &&
- git update-ref --stdin <input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 200 |
+ git update-ref --stdin &&
git pack-refs &&
cat >expect <<-EOF &&
@@ -178,8 +178,8 @@ test_expect_success 'restart interval at every single record' '
(
cd repo &&
test_commit initial &&
- test_seq -f "update refs/heads/branch-%d HEAD" 10 >input &&
- git update-ref --stdin <input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 10 |
+ git update-ref --stdin &&
git -c reftable.restartInterval=1 pack-refs &&
cat >expect <<-EOF &&
@@ -218,8 +218,8 @@ test_expect_success 'object index gets written by default with ref index' '
(
cd repo &&
test_commit initial &&
- test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
- git update-ref --stdin <input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 5 |
+ git update-ref --stdin &&
git -c reftable.blockSize=100 pack-refs &&
cat >expect <<-EOF &&
@@ -253,8 +253,8 @@ test_expect_success 'object index can be disabled' '
(
cd repo &&
test_commit initial &&
- test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
- git update-ref --stdin <input &&
+ test_seq -f "update refs/heads/branch-%d HEAD" 5 |
+ git update-ref --stdin &&
git -c reftable.blockSize=100 -c reftable.indexObjects=false pack-refs &&
cat >expect <<-EOF &&
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index db6585b8d8..b2858a9061 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -1380,16 +1380,16 @@ test_expect_success 'fails with duplicate ref update via symref' '
test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
(
- test_seq -f "create refs/heads/%d HEAD" 33 >large_input &&
- run_with_limited_open_files git update-ref --stdin <large_input &&
+ test_seq -f "create refs/heads/%d HEAD" 33 |
+ run_with_limited_open_files git update-ref --stdin &&
git rev-parse --verify -q refs/heads/33
)
'
test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
(
- test_seq -f "delete refs/heads/%d HEAD" 33 >large_input &&
- run_with_limited_open_files git update-ref --stdin <large_input &&
+ test_seq -f "delete refs/heads/%d HEAD" 33 |
+ run_with_limited_open_files git update-ref --stdin &&
test_must_fail git rev-parse --verify -q refs/heads/33
)
'
diff --git a/t/t1460-refs-migrate.sh b/t/t1460-refs-migrate.sh
index 0e1116a319..5246468024 100755
--- a/t/t1460-refs-migrate.sh
+++ b/t/t1460-refs-migrate.sh
@@ -276,11 +276,11 @@ test_expect_success 'multiple reftable blocks with multiple entries' '
test_when_finished "rm -rf repo" &&
git init --ref-format=files repo &&
test_commit -C repo first &&
- printf "create refs/heads/ref-%d HEAD\n" $(test_seq 5000) >stdin &&
- git -C repo update-ref --stdin <stdin &&
+ test_seq -f "create refs/heads/ref-%d HEAD" 5000 |
+ git -C repo update-ref --stdin &&
test_commit -C repo second &&
- printf "update refs/heads/ref-%d HEAD\n" $(test_seq 3000) >stdin &&
- git -C repo update-ref --stdin <stdin &&
+ test_seq -f "update refs/heads/ref-%d HEAD" 3000 |
+ git -C repo update-ref --stdin &&
test_migration repo reftable true
'
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 027dedd976..df513a4269 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -176,8 +176,7 @@ test_expect_success EXPENSIVE,UNZIP,UNZIP_ZIP64_SUPPORT \
blob=$(echo $s | git hash-object -w --stdin) &&
# create tree containing 65500 entries of that blob
- test_seq -f "100644 blob $blob\t%d" 1 65500 >tree &&
- tree=$(git mktree <tree) &&
+ tree=$(test_seq -f "100644 blob $blob\t%d" 1 65500 | git mktree) &&
# zip it, creating an archive a bit bigger than 4GB
git archive -0 -o many-big.zip $tree &&
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 17a46fd3ba..44ec875aef 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -134,8 +134,8 @@ test_expect_success 'pre-receive hook that forgets to read its input' '
EOF
rm -f victim.git/hooks/update victim.git/hooks/post-update &&
- printf "create refs/heads/branch_%d main\n" $(test_seq 100 999) >input &&
- git update-ref --stdin <input &&
+ test_seq -f "create refs/heads/branch_%d main" 100 999 |
+ git update-ref --stdin &&
git push ./victim.git "+refs/heads/*:refs/heads/*"
'
--
2.53.0
next reply other threads:[~2026-02-18 18:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 18:10 Aaron Plattner [this message]
2026-02-19 17:09 ` [PATCH] t: use test_seq -f and pipes in a few more places Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260218181019.1705160-1-aplattner@nvidia.com \
--to=aplattner@nvidia.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox