Skip to content

Commit 964a856

Browse files
committed
Merge branch 'sm/no-git-in-upstream-of-pipe-in-tests'
Test fixes. * sm/no-git-in-upstream-of-pipe-in-tests: t0030-t0050: avoid pipes with Git on LHS t0001-t0028: avoid pipes with Git on LHS t0003: avoid pipes with Git on LHS
2 parents 74cc1aa + eed36fc commit 964a856

File tree

7 files changed

+72
-45
lines changed

7 files changed

+72
-45
lines changed

t/t0000-basic.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,8 @@ test_expect_success 'update-index D/F conflict' '
10891089
mv path2 path0 &&
10901090
mv tmp path2 &&
10911091
git update-index --add --replace path2 path0/file2 &&
1092-
numpath0=$(git ls-files path0 | wc -l) &&
1092+
git ls-files path0 >tmp &&
1093+
numpath0=$(wc -l <tmp) &&
10931094
test $numpath0 = 1
10941095
'
10951096

@@ -1103,13 +1104,14 @@ test_expect_success 'very long name in the index handled sanely' '
11031104
11041105
>path4 &&
11051106
git update-index --add path4 &&
1107+
git ls-files -s path4 >tmp &&
11061108
(
1107-
git ls-files -s path4 |
1108-
sed -e "s/ .*/ /" |
1109+
sed -e "s/ .*/ /" tmp |
11091110
tr -d "\012" &&
11101111
echo "$a"
11111112
) | git update-index --index-info &&
1112-
len=$(git ls-files "a*" | wc -c) &&
1113+
git ls-files "a*" >tmp &&
1114+
len=$(wc -c <tmp) &&
11131115
test $len = 4098
11141116
'
11151117

t/t0003-attributes.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,18 @@ test_expect_success 'attribute test: read paths from stdin' '
205205
test_expect_success 'attribute test: --all option' '
206206
grep -v unspecified <expect-all | sort >specified-all &&
207207
sed -e "s/:.*//" <expect-all | uniq >stdin-all &&
208-
git check-attr --stdin --all <stdin-all | sort >actual &&
208+
git check-attr --stdin --all <stdin-all >tmp &&
209+
sort tmp >actual &&
209210
test_cmp specified-all actual
210211
'
211212

212213
test_expect_success 'attribute test: --cached option' '
213-
git check-attr --cached --stdin --all <stdin-all | sort >actual &&
214+
git check-attr --cached --stdin --all <stdin-all >tmp &&
215+
sort tmp >actual &&
214216
test_must_be_empty actual &&
215217
git add .gitattributes a/.gitattributes a/b/.gitattributes &&
216-
git check-attr --cached --stdin --all <stdin-all | sort >actual &&
218+
git check-attr --cached --stdin --all <stdin-all >tmp &&
219+
sort tmp >actual &&
217220
test_cmp specified-all actual
218221
'
219222

t/t0022-crlf-rename.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ test_expect_success setup '
2424

2525
test_expect_success 'diff -M' '
2626
27-
git diff-tree -M -r --name-status HEAD^ HEAD |
28-
sed -e "s/R[0-9]*/RNUM/" >actual &&
27+
git diff-tree -M -r --name-status HEAD^ HEAD >tmp &&
28+
sed -e "s/R[0-9]*/RNUM/" tmp >actual &&
2929
echo "RNUM sample elpmas" >expect &&
3030
test_cmp expect actual
3131

t/t0025-crlf-renormalize.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test_expect_success 'renormalize CRLF in repo' '
2222
i/lf w/lf attr/text=auto LF.txt
2323
i/lf w/mixed attr/text=auto CRLF_mix_LF.txt
2424
EOF
25-
git ls-files --eol |
26-
sed -e "s/ / /g" -e "s/ */ /g" |
25+
git ls-files --eol >tmp &&
26+
sed -e "s/ / /g" -e "s/ */ /g" tmp |
2727
sort >actual &&
2828
test_cmp expect actual
2929
'

t/t0027-auto-crlf.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ checkout_files () {
311311
i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
312312
i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
313313
EOF
314-
git ls-files --eol crlf_false_attr__* |
315-
sed -e "s/ / /g" -e "s/ */ /g" |
314+
git ls-files --eol crlf_false_attr__* >tmp &&
315+
sed -e "s/ / /g" -e "s/ */ /g" tmp |
316316
sort >actual &&
317317
test_cmp expect actual
318318
'
@@ -359,12 +359,12 @@ test_expect_success 'ls-files --eol -o Text/Binary' '
359359
i/ w/crlf TeBi_126_CL
360360
i/ w/-text TeBi_126_CLC
361361
EOF
362-
git ls-files --eol -o |
362+
git ls-files --eol -o >tmp &&
363363
sed -n -e "/TeBi_/{s!attr/[ ]*!!g
364364
s! ! !g
365365
s! *! !g
366366
p
367-
}" | sort >actual &&
367+
}" tmp | sort >actual &&
368368
test_cmp expect actual
369369
'
370370

@@ -617,8 +617,8 @@ test_expect_success 'ls-files --eol -d -z' '
617617
i/lf w/ crlf_false_attr__LF.txt
618618
i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
619619
EOF
620-
git ls-files --eol -d |
621-
sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" |
620+
git ls-files --eol -d >tmp &&
621+
sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" tmp |
622622
sort >actual &&
623623
test_cmp expect actual
624624
'

t/t0030-stripspace.sh

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ s40=' '
1313
sss="$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40" # 400
1414
ttt="$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40" # 400
1515

16+
printf_git_stripspace () {
17+
printf "$1" | git stripspace
18+
}
19+
1620
test_expect_success \
1721
'long lines without spaces should be unchanged' '
1822
echo "$ttt" >expect &&
@@ -225,32 +229,38 @@ test_expect_success \
225229

226230
test_expect_success \
227231
'text without newline at end should end with newline' '
228-
test $(printf "$ttt" | git stripspace | wc -l) -gt 0 &&
229-
test $(printf "$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
230-
test $(printf "$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
231-
test $(printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0
232+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" &&
233+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" &&
234+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" &&
235+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt"
232236
'
233237

234238
# text plus spaces at the end:
235239

236240
test_expect_success \
237241
'text plus spaces without newline at end should end with newline' '
238-
test $(printf "$ttt$sss" | git stripspace | wc -l) -gt 0 &&
239-
test $(printf "$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
240-
test $(printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
241-
test $(printf "$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
242-
test $(printf "$ttt$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
243-
test $(printf "$ttt$sss$sss$sss" | git stripspace | wc -l) -gt 0
242+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" &&
243+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" &&
244+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" &&
245+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" &&
246+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" &&
247+
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss"
244248
'
245249

246250
test_expect_success \
247251
'text plus spaces without newline at end should not show spaces' '
248-
! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
249-
! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
250-
! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
251-
! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
252-
! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
253-
! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
252+
printf "$ttt$sss" | git stripspace >tmp &&
253+
! grep " " tmp >/dev/null &&
254+
printf "$ttt$ttt$sss" | git stripspace >tmp &&
255+
! grep " " tmp >/dev/null &&
256+
printf "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
257+
! grep " " tmp >/dev/null &&
258+
printf "$ttt$sss$sss" | git stripspace >tmp &&
259+
! grep " " tmp >/dev/null &&
260+
printf "$ttt$ttt$sss$sss" | git stripspace >tmp &&
261+
! grep " " tmp >/dev/null &&
262+
printf "$ttt$sss$sss$sss" | git stripspace >tmp &&
263+
! grep " " tmp >/dev/null
254264
'
255265

256266
test_expect_success \
@@ -282,12 +292,18 @@ test_expect_success \
282292

283293
test_expect_success \
284294
'text plus spaces at end should not show spaces' '
285-
! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
286-
! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
287-
! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
288-
! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
289-
! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
290-
! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
295+
echo "$ttt$sss" | git stripspace >tmp &&
296+
! grep " " tmp >/dev/null &&
297+
echo "$ttt$ttt$sss" | git stripspace >tmp &&
298+
! grep " " tmp >/dev/null &&
299+
echo "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
300+
! grep " " tmp >/dev/null &&
301+
echo "$ttt$sss$sss" | git stripspace >tmp &&
302+
! grep " " tmp >/dev/null &&
303+
echo "$ttt$ttt$sss$sss" | git stripspace >tmp &&
304+
! grep " " tmp >/dev/null &&
305+
echo "$ttt$sss$sss$sss" | git stripspace >tmp &&
306+
! grep " " tmp >/dev/null
291307
'
292308

293309
test_expect_success \
@@ -339,11 +355,16 @@ test_expect_success \
339355

340356
test_expect_success \
341357
'spaces without newline at end should not show spaces' '
342-
! (printf "" | git stripspace | grep " " >/dev/null) &&
343-
! (printf "$sss" | git stripspace | grep " " >/dev/null) &&
344-
! (printf "$sss$sss" | git stripspace | grep " " >/dev/null) &&
345-
! (printf "$sss$sss$sss" | git stripspace | grep " " >/dev/null) &&
346-
! (printf "$sss$sss$sss$sss" | git stripspace | grep " " >/dev/null)
358+
printf "" | git stripspace >tmp &&
359+
! grep " " tmp >/dev/null &&
360+
printf "$sss" | git stripspace >tmp &&
361+
! grep " " tmp >/dev/null &&
362+
printf "$sss$sss" | git stripspace >tmp &&
363+
! grep " " tmp >/dev/null &&
364+
printf "$sss$sss$sss" | git stripspace >tmp &&
365+
! grep " " tmp >/dev/null &&
366+
printf "$sss$sss$sss$sss" | git stripspace >tmp &&
367+
! grep " " tmp >/dev/null
347368
'
348369

349370
test_expect_success \

t/t0050-filesystem.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
104104
rm camelcase &&
105105
echo 1 >CamelCase &&
106106
git add CamelCase &&
107-
camel=$(git ls-files | grep -i camelcase) &&
107+
git ls-files >tmp &&
108+
camel=$(grep -i camelcase tmp) &&
108109
test $(echo "$camel" | wc -l) = 1 &&
109110
test "z$(git cat-file blob :$camel)" = z1
110111
'

0 commit comments

Comments
 (0)