Skip to content

Commit 0678e01

Browse files
aaronp24gitster
authored andcommitted
t: use test_seq -f and pipes in a few more places
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit 0678e01

6 files changed

Lines changed: 29 additions & 34 deletions

t/pack-refs-tests.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ do
354354
355355
# Create 14 additional references, which brings us to
356356
# 15 together with the default branch.
357-
printf "create refs/heads/loose-%d HEAD\n" $(test_seq 14) >stdin &&
358-
git update-ref --stdin <stdin &&
357+
test_seq -f "create refs/heads/loose-%d HEAD" 14 |
358+
git update-ref --stdin &&
359359
test_path_is_missing .git/packed-refs &&
360360
git ${pack_refs} --auto --all &&
361361
test_path_is_missing .git/packed-refs &&
@@ -379,8 +379,8 @@ do
379379
test_line_count = 2 .git/packed-refs &&
380380
381381
# Create 15 loose references.
382-
printf "create refs/heads/loose-%d HEAD\n" $(test_seq 15) >stdin &&
383-
git update-ref --stdin <stdin &&
382+
test_seq -f "create refs/heads/loose-%d HEAD" 15 |
383+
git update-ref --stdin &&
384384
git ${pack_refs} --auto --all &&
385385
test_line_count = 2 .git/packed-refs &&
386386
@@ -401,27 +401,23 @@ do
401401
402402
# Create 99 packed refs. This should cause the heuristic
403403
# to require more than the minimum amount of loose refs.
404-
test_seq 99 |
405-
while read i
406-
do
407-
printf "create refs/heads/packed-%d HEAD\n" $i || return 1
408-
done >stdin &&
409-
git update-ref --stdin <stdin &&
404+
test_seq -f "create refs/heads/packed-%d HEAD" 99 |
405+
git update-ref --stdin &&
410406
git ${pack_refs} --all &&
411407
test_line_count = 101 .git/packed-refs &&
412408
413409
# Create 24 loose refs, which should not yet cause us to repack.
414-
printf "create refs/heads/loose-%d HEAD\n" $(test_seq 24) >stdin &&
415-
git update-ref --stdin <stdin &&
410+
test_seq -f "create refs/heads/loose-%d HEAD" 24 |
411+
git update-ref --stdin &&
416412
git ${pack_refs} --auto --all &&
417413
test_line_count = 101 .git/packed-refs &&
418414
419415
# Create another handful of refs to cross the border.
420416
# Note that we explicitly do not check for strict
421417
# boundaries here, as this also depends on the size of
422418
# the object hash.
423-
printf "create refs/heads/addn-%d HEAD\n" $(test_seq 10) >stdin &&
424-
git update-ref --stdin <stdin &&
419+
test_seq -f "create refs/heads/addn-%d HEAD" 10 |
420+
git update-ref --stdin &&
425421
git ${pack_refs} --auto --all &&
426422
test_line_count = 135 .git/packed-refs
427423
)

t/t0613-reftable-write-options.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ test_expect_success 'many refs results in multiple blocks' '
6868
(
6969
cd repo &&
7070
test_commit initial &&
71-
test_seq -f "update refs/heads/branch-%d HEAD" 200 >input &&
72-
git update-ref --stdin <input &&
71+
test_seq -f "update refs/heads/branch-%d HEAD" 200 |
72+
git update-ref --stdin &&
7373
git pack-refs &&
7474
7575
cat >expect <<-EOF &&
@@ -178,8 +178,8 @@ test_expect_success 'restart interval at every single record' '
178178
(
179179
cd repo &&
180180
test_commit initial &&
181-
test_seq -f "update refs/heads/branch-%d HEAD" 10 >input &&
182-
git update-ref --stdin <input &&
181+
test_seq -f "update refs/heads/branch-%d HEAD" 10 |
182+
git update-ref --stdin &&
183183
git -c reftable.restartInterval=1 pack-refs &&
184184
185185
cat >expect <<-EOF &&
@@ -218,8 +218,8 @@ test_expect_success 'object index gets written by default with ref index' '
218218
(
219219
cd repo &&
220220
test_commit initial &&
221-
test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
222-
git update-ref --stdin <input &&
221+
test_seq -f "update refs/heads/branch-%d HEAD" 5 |
222+
git update-ref --stdin &&
223223
git -c reftable.blockSize=100 pack-refs &&
224224
225225
cat >expect <<-EOF &&
@@ -253,8 +253,8 @@ test_expect_success 'object index can be disabled' '
253253
(
254254
cd repo &&
255255
test_commit initial &&
256-
test_seq -f "update refs/heads/branch-%d HEAD" 5 >input &&
257-
git update-ref --stdin <input &&
256+
test_seq -f "update refs/heads/branch-%d HEAD" 5 |
257+
git update-ref --stdin &&
258258
git -c reftable.blockSize=100 -c reftable.indexObjects=false pack-refs &&
259259
260260
cat >expect <<-EOF &&

t/t1400-update-ref.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,16 +1380,16 @@ test_expect_success 'fails with duplicate ref update via symref' '
13801380

13811381
test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
13821382
(
1383-
test_seq -f "create refs/heads/%d HEAD" 33 >large_input &&
1384-
run_with_limited_open_files git update-ref --stdin <large_input &&
1383+
test_seq -f "create refs/heads/%d HEAD" 33 |
1384+
run_with_limited_open_files git update-ref --stdin &&
13851385
git rev-parse --verify -q refs/heads/33
13861386
)
13871387
'
13881388

13891389
test_expect_success ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
13901390
(
1391-
test_seq -f "delete refs/heads/%d HEAD" 33 >large_input &&
1392-
run_with_limited_open_files git update-ref --stdin <large_input &&
1391+
test_seq -f "delete refs/heads/%d HEAD" 33 |
1392+
run_with_limited_open_files git update-ref --stdin &&
13931393
test_must_fail git rev-parse --verify -q refs/heads/33
13941394
)
13951395
'

t/t1460-refs-migrate.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ test_expect_success 'multiple reftable blocks with multiple entries' '
276276
test_when_finished "rm -rf repo" &&
277277
git init --ref-format=files repo &&
278278
test_commit -C repo first &&
279-
printf "create refs/heads/ref-%d HEAD\n" $(test_seq 5000) >stdin &&
280-
git -C repo update-ref --stdin <stdin &&
279+
test_seq -f "create refs/heads/ref-%d HEAD" 5000 |
280+
git -C repo update-ref --stdin &&
281281
test_commit -C repo second &&
282-
printf "update refs/heads/ref-%d HEAD\n" $(test_seq 3000) >stdin &&
283-
git -C repo update-ref --stdin <stdin &&
282+
test_seq -f "update refs/heads/ref-%d HEAD" 3000 |
283+
git -C repo update-ref --stdin &&
284284
test_migration repo reftable true
285285
'
286286

t/t5004-archive-corner-cases.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ test_expect_success EXPENSIVE,UNZIP,UNZIP_ZIP64_SUPPORT \
176176
blob=$(echo $s | git hash-object -w --stdin) &&
177177
178178
# create tree containing 65500 entries of that blob
179-
test_seq -f "100644 blob $blob\t%d" 1 65500 >tree &&
180-
tree=$(git mktree <tree) &&
179+
tree=$(test_seq -f "100644 blob $blob\t%d" 1 65500 | git mktree) &&
181180
182181
# zip it, creating an archive a bit bigger than 4GB
183182
git archive -0 -o many-big.zip $tree &&

t/t5401-update-hooks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ test_expect_success 'pre-receive hook that forgets to read its input' '
134134
EOF
135135
rm -f victim.git/hooks/update victim.git/hooks/post-update &&
136136
137-
printf "create refs/heads/branch_%d main\n" $(test_seq 100 999) >input &&
138-
git update-ref --stdin <input &&
137+
test_seq -f "create refs/heads/branch_%d main" 100 999 |
138+
git update-ref --stdin &&
139139
git push ./victim.git "+refs/heads/*:refs/heads/*"
140140
'
141141

0 commit comments

Comments
 (0)