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
This commit is contained in:
Junio C Hamano 2022-03-21 15:14:23 -07:00
commit 964a856cbe
7 changed files with 72 additions and 45 deletions

View file

@ -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
'

View file

@ -205,15 +205,18 @@ test_expect_success 'attribute test: read paths from stdin' '
test_expect_success 'attribute test: --all option' '
grep -v unspecified <expect-all | sort >specified-all &&
sed -e "s/:.*//" <expect-all | uniq >stdin-all &&
git check-attr --stdin --all <stdin-all | sort >actual &&
git check-attr --stdin --all <stdin-all >tmp &&
sort tmp >actual &&
test_cmp specified-all actual
'
test_expect_success 'attribute test: --cached option' '
git check-attr --cached --stdin --all <stdin-all | sort >actual &&
git check-attr --cached --stdin --all <stdin-all >tmp &&
sort tmp >actual &&
test_must_be_empty actual &&
git add .gitattributes a/.gitattributes a/b/.gitattributes &&
git check-attr --cached --stdin --all <stdin-all | sort >actual &&
git check-attr --cached --stdin --all <stdin-all >tmp &&
sort tmp >actual &&
test_cmp specified-all actual
'

View file

@ -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

View file

@ -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
'

View file

@ -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
'
@ -617,8 +617,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
'

View file

@ -13,6 +13,10 @@ s40=' '
sss="$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40" # 400
ttt="$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40" # 400
printf_git_stripspace () {
printf "$1" | git stripspace
}
test_expect_success \
'long lines without spaces should be unchanged' '
echo "$ttt" >expect &&
@ -225,32 +229,38 @@ test_expect_success \
test_expect_success \
'text without newline at end should end with newline' '
test $(printf "$ttt" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt"
'
# text plus spaces at the end:
test_expect_success \
'text plus spaces without newline at end should end with newline' '
test $(printf "$ttt$sss" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
test $(printf "$ttt$sss$sss$sss" | git stripspace | wc -l) -gt 0
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" &&
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss"
'
test_expect_success \
'text plus spaces without newline at end should not show spaces' '
! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
printf "$ttt$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$ttt$ttt$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$ttt$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$ttt$ttt$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$ttt$sss$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null
'
test_expect_success \
@ -282,12 +292,18 @@ test_expect_success \
test_expect_success \
'text plus spaces at end should not show spaces' '
! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
echo "$ttt$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
echo "$ttt$ttt$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
echo "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
echo "$ttt$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
echo "$ttt$ttt$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
echo "$ttt$sss$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null
'
test_expect_success \
@ -339,11 +355,16 @@ test_expect_success \
test_expect_success \
'spaces without newline at end should not show spaces' '
! (printf "" | git stripspace | grep " " >/dev/null) &&
! (printf "$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$sss$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$sss$sss$sss" | git stripspace | grep " " >/dev/null) &&
! (printf "$sss$sss$sss$sss" | git stripspace | grep " " >/dev/null)
printf "" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$sss$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null &&
printf "$sss$sss$sss$sss" | git stripspace >tmp &&
! grep " " tmp >/dev/null
'
test_expect_success \

View file

@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
rm camelcase &&
echo 1 >CamelCase &&
git add CamelCase &&
camel=$(git ls-files | grep -i camelcase) &&
git ls-files >tmp &&
camel=$(grep -i camelcase tmp) &&
test $(echo "$camel" | wc -l) = 1 &&
test "z$(git cat-file blob :$camel)" = z1
'