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 <shivam828787@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shubham Mishra committed Mar 12, 2022 at 11:51 UTC 9b6d1fc48a29abdd49c267ce1bf06bac5151a0e4
4 files changed +16 -14
t/t0000-basic.sh
+6 -4
@@ -1089,7 +1089,8 @@ test_expect_success 'update-index D/F conflict' '
1089 mv path2 path0 &&
1090 mv tmp path2 &&
1091 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) &&
1094 test $numpath0 = 1
1095 '
1096
@@ -1103,13 +1104,14 @@ test_expect_success 'very long name in the index handled sanely' '
1104
1105 >path4 &&
1106 git update-index --add path4 &&
1107 + git ls-files -s path4 >tmp &&
1108 (
1107 - git ls-files -s path4 |
1108 - sed -e "s/ .*/ /" |
1109 + sed -e "s/ .*/ /" tmp |
1110 tr -d "\012" &&
1111 echo "$a"
1112 ) | git update-index --index-info &&
1112 - len=$(git ls-files "a*" | wc -c) &&
1113 + git ls-files "a*" >tmp &&
1114 + len=$(wc -c <tmp) &&
1115 test $len = 4098
1116 '
1117
t/t0022-crlf-rename.sh
+2 -2
@@ -24,8 +24,8 @@ test_expect_success setup '
24
25 test_expect_success 'diff -M' '
26
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 &&
29 echo "RNUM sample elpmas" >expect &&
30 test_cmp expect actual
31
t/t0025-crlf-renormalize.sh
+2 -2
@@ -22,8 +22,8 @@ test_expect_success 'renormalize CRLF in repo' '
22 i/lf w/lf attr/text=auto LF.txt
23 i/lf w/mixed attr/text=auto CRLF_mix_LF.txt
24 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 |
27 sort >actual &&
28 test_cmp expect actual
29 '
t/t0027-auto-crlf.sh
+6 -6
@@ -311,8 +311,8 @@ checkout_files () {
311 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
312 i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
313 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 |
316 sort >actual &&
317 test_cmp expect actual
318 '
@@ -359,12 +359,12 @@ test_expect_success 'ls-files --eol -o Text/Binary' '
359 i/ w/crlf TeBi_126_CL
360 i/ w/-text TeBi_126_CLC
361 EOF
362 - git ls-files --eol -o |
362 + git ls-files --eol -o >tmp &&
363 sed -n -e "/TeBi_/{s!attr/[ ]*!!g
364 s! ! !g
365 s! *! !g
366 p
367 - }" | sort >actual &&
367 + }" tmp | sort >actual &&
368 test_cmp expect actual
369 '
370
@@ -611,8 +611,8 @@ test_expect_success 'ls-files --eol -d -z' '
611 i/lf w/ crlf_false_attr__LF.txt
612 i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
613 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 |
616 sort >actual &&
617 test_cmp expect actual
618 '