]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t0001-t0028: avoid pipes with Git on LHS
authorShubham Mishra <shivam828787@gmail.com>
Sat, 12 Mar 2022 06:21:25 +0000 (11:51 +0530)
committerJunio C Hamano <gitster@pobox.com>
Sun, 13 Mar 2022 00:22:01 +0000 (16:22 -0800)
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>
t/t0000-basic.sh
t/t0022-crlf-rename.sh
t/t0025-crlf-renormalize.sh
t/t0027-auto-crlf.sh

index b007f0efef26294d2aa0a0665d37d522eb60f103..9dcbf518a7828e25965bda8f16884867c768b62a 100755 (executable)
@@ -1089,7 +1089,8 @@ test_expect_success 'update-index D/F conflict' '
        mv path2 path0 &&
        mv tmp path2 &&
        git update-index --add --replace path2 path0/file2 &&
-       numpath0=$(git ls-files path0 | wc -l) &&
+       git ls-files path0 >tmp &&
+       numpath0=$(wc -l <tmp) &&
        test $numpath0 = 1
 '
 
@@ -1103,13 +1104,14 @@ test_expect_success 'very long name in the index handled sanely' '
 
        >path4 &&
        git update-index --add path4 &&
+       git ls-files -s path4 >tmp &&
        (
-               git ls-files -s path4 |
-               sed -e "s/      .*/     /" |
+               sed -e "s/      .*/     /" tmp |
                tr -d "\012" &&
                echo "$a"
        ) | git update-index --index-info &&
-       len=$(git ls-files "a*" | wc -c) &&
+       git ls-files "a*" >tmp &&
+       len=$(wc -c <tmp) &&
        test $len = 4098
 '
 
index c1a331e9e939fa975ba038934e885bb2fe93b63c..9fe98912511d3b6cb050aa51e33906caf7fb51c5 100755 (executable)
@@ -24,8 +24,8 @@ test_expect_success setup '
 
 test_expect_success 'diff -M' '
 
-       git diff-tree -M -r --name-status HEAD^ HEAD |
-       sed -e "s/R[0-9]*/RNUM/" >actual &&
+       git diff-tree -M -r --name-status HEAD^ HEAD >tmp &&
+       sed -e "s/R[0-9]*/RNUM/" tmp >actual &&
        echo "RNUM      sample  elpmas" >expect &&
        test_cmp expect actual
 
index 81447978b7f66a7a2169341f0b6da649e106e8bd..f7202c192e7b63e07c904fe9dcf1b76252d8808d 100755 (executable)
@@ -22,8 +22,8 @@ test_expect_success 'renormalize CRLF in repo' '
        i/lf w/lf attr/text=auto LF.txt
        i/lf w/mixed attr/text=auto CRLF_mix_LF.txt
        EOF
-       git ls-files --eol |
-       sed -e "s/      / /g" -e "s/  */ /g" |
+       git ls-files --eol >tmp &&
+       sed -e "s/      / /g" -e "s/  */ /g" tmp |
        sort >actual &&
        test_cmp expect actual
 '
index 4a5c5c602cfa8f53ecb9e329a20e67a008fb0e00..671fd694eefa8dd38418c8d5a8167461675c89b3 100755 (executable)
@@ -311,8 +311,8 @@ checkout_files () {
                i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt
                i/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt
                EOF
-               git ls-files --eol crlf_false_attr__* |
-               sed -e "s/      / /g" -e "s/  */ /g" |
+               git ls-files --eol crlf_false_attr__* >tmp &&
+               sed -e "s/      / /g" -e "s/  */ /g" tmp |
                sort >actual &&
                test_cmp expect actual
        '
@@ -359,12 +359,12 @@ test_expect_success 'ls-files --eol -o Text/Binary' '
        i/ w/crlf TeBi_126_CL
        i/ w/-text TeBi_126_CLC
        EOF
-       git ls-files --eol -o |
+       git ls-files --eol -o >tmp &&
        sed -n -e "/TeBi_/{s!attr/[     ]*!!g
        s!      ! !g
        s!  *! !g
        p
-       }" | sort >actual &&
+       }" tmp | sort >actual &&
        test_cmp expect actual
 '
 
@@ -611,8 +611,8 @@ test_expect_success 'ls-files --eol -d -z' '
        i/lf w/ crlf_false_attr__LF.txt
        i/mixed w/ crlf_false_attr__CRLF_mix_LF.txt
        EOF
-       git ls-files --eol -d |
-       sed -e "s!attr/[^       ]*!!g" -e "s/   / /g" -e "s/  */ /g" |
+       git ls-files --eol -d >tmp &&
+       sed -e "s!attr/[^       ]*!!g" -e "s/   / /g" -e "s/  */ /g" tmp |
        sort >actual &&
        test_cmp expect actual
 '