@@ -38,7 +38,8 @@ test_expect_success 'Test with no pathspecs' '
3838'
3939
4040test_expect_success ' Post-check that foo is in the index' '
41- git ls-files foo | grep foo
41+ git ls-files foo >actual &&
42+ grep foo actual
4243'
4344
4445test_expect_success ' Test that "git add -- -q" works' '
@@ -195,8 +196,9 @@ test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries'
195196 echo new > file &&
196197 echo new > symlink &&
197198 git add file symlink &&
198- git ls-files --stage | grep "^100755 .* 0 file$" &&
199- git ls-files --stage | grep "^120000 .* 0 symlink$"
199+ git ls-files --stage >actual &&
200+ grep "^100755 .* 0 file$" actual &&
201+ grep "^120000 .* 0 symlink$" actual
200202'
201203
202204test_expect_success ' git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' '
@@ -212,8 +214,9 @@ test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over st
212214 echo new > file &&
213215 echo new > symlink &&
214216 git add file symlink &&
215- git ls-files --stage | grep "^100755 .* 0 file$" &&
216- git ls-files --stage | grep "^120000 .* 0 symlink$"
217+ git ls-files --stage >actual &&
218+ grep "^100755 .* 0 file$" actual &&
219+ grep "^120000 .* 0 symlink$" actual
217220'
218221
219222test_expect_success ' git add --refresh' '
@@ -254,7 +257,8 @@ test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unr
254257 date >foo2 &&
255258 chmod 0 foo2 &&
256259 test_must_fail git add --verbose . &&
257- ! ( git ls-files foo1 | grep foo1 )
260+ git ls-files foo1 >actual &&
261+ ! grep foo1 actual
258262'
259263
260264rm -f foo2
@@ -265,7 +269,8 @@ test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '
265269 date >foo2 &&
266270 chmod 0 foo2 &&
267271 test_must_fail git add --verbose --ignore-errors . &&
268- git ls-files foo1 | grep foo1
272+ git ls-files foo1 >actual &&
273+ grep foo1 actual
269274'
270275
271276rm -f foo2
@@ -277,7 +282,8 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '
277282 date >foo2 &&
278283 chmod 0 foo2 &&
279284 test_must_fail git add --verbose . &&
280- git ls-files foo1 | grep foo1
285+ git ls-files foo1 >actual &&
286+ grep foo1 actual
281287'
282288rm -f foo2
283289
@@ -288,7 +294,8 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '
288294 date >foo2 &&
289295 chmod 0 foo2 &&
290296 test_must_fail git add --verbose . &&
291- ! ( git ls-files foo1 | grep foo1 )
297+ git ls-files foo1 >actual &&
298+ ! grep foo1 actual
292299'
293300rm -f foo2
294301
@@ -299,7 +306,8 @@ test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '
299306 date >foo2 &&
300307 chmod 0 foo2 &&
301308 test_must_fail git add --verbose --no-ignore-errors . &&
302- ! ( git ls-files foo1 | grep foo1 ) &&
309+ git ls-files foo1 >actual &&
310+ ! grep foo1 actual &&
303311 git config add.ignore-errors 0
304312'
305313rm -f foo2
@@ -308,8 +316,10 @@ test_expect_success BSLASHPSPEC "git add 'fo\\[ou\\]bar' ignores foobar" '
308316 git reset --hard &&
309317 touch fo\[ou\]bar foobar &&
310318 git add ' \' ' fo\[ou\]bar' \' ' &&
311- git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar &&
312- ! ( git ls-files foobar | grep foobar )
319+ git ls-files fo\[ou\]bar >actual &&
320+ grep -F fo\[ou\]bar actual &&
321+ git ls-files foobar >actual &&
322+ ! grep foobar actual
313323'
314324
315325test_expect_success ' git add to resolve conflicts on otherwise ignored path' '
@@ -326,7 +336,8 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
326336
327337test_expect_success ' "add non-existent" should fail' '
328338 test_must_fail git add non-existent &&
329- ! (git ls-files | grep "non-existent")
339+ git ls-files >actual &&
340+ ! grep "non-existent" actual
330341'
331342
332343test_expect_success ' git add -A on empty repo does not error out' '
@@ -536,9 +547,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
536547 touch x y z sub/a sub/dir/b &&
537548 git add -A &&
538549 git add --chmod=+x . &&
539- test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&
550+ git ls-files --stage >actual &&
551+ ! grep ^100644 actual &&
540552 git add --chmod=-x . &&
541- test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
553+ git ls-files --stage >actual &&
554+ ! grep ^100755 actual
542555 )
543556'
544557
0 commit comments