t0003: 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 Feb 23, 2022 at 17:23 UTC ae5d569bb22ea4e889c9a2da757ed0c253ec1fc1
1 file changed +6 -3
t/t0003-attributes.sh
+6 -3
@@ -205,15 +205,18 @@ test_expect_success 'attribute test: read paths from stdin' '
205 test_expect_success 'attribute test: --all option' '
206 grep -v unspecified <expect-all | sort >specified-all &&
207 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 &&
210 test_cmp specified-all actual
211 '
212
213 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 &&
216 test_must_be_empty actual &&
217 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 &&
220 test_cmp specified-all actual
221 '
222