Skip to content

Commit 9b6d1fc

Browse files
Shubham8287gitster
authored andcommitted
t0001-t0028: avoid pipes with Git on LHS
Pipes ignore error codes of LHS command and thus we should not use them with Git in tests. As an alternative, use a 'tmp' file to write the Git output so we can test the exit code. Signed-off-by: Shubham Mishra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae5d569 commit 9b6d1fc

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
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/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

@@ -611,8 +611,8 @@ test_expect_success 'ls-files --eol -d -z' '
611611
i/lf w/ crlf_false_attr__LF.txt
612612
i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
613613
EOF
614-
git ls-files --eol -d |
615-
sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" |
614+
git ls-files --eol -d >tmp &&
615+
sed -e "s!attr/[^ ]*!!g" -e "s/ / /g" -e "s/ */ /g" tmp |
616616
sort >actual &&
617617
test_cmp expect actual
618618
'

0 commit comments

Comments
 (0)