t4129: prevent loss of exit code due to the use of pipes

Piping the output of git commands like git-ls-files to another command (grep in this case) hides the exit code returned by these commands. Prevent this by storing the output of git-ls-files to a temporary file and then "grep-ping" from that file. Replace grep with test_grep as the latter is more verbose when it fails. Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chandra Pratap committed Jan 10, 2024 at 12:54 UTC 1260914190ad737029de6f4f61851180a4ccce56
1 file changed +4 -2
t/t4129-apply-samemode.sh
+4 -2
@@ -41,7 +41,8 @@ test_expect_success FILEMODE 'same mode (index only)' '
41 chmod +x file &&
42 git add file &&
43 git apply --cached patch-0.txt &&
44 - git ls-files -s file | grep "^100755"
44 + git ls-files -s file >ls-files-output &&
45 + test_grep "^100755" ls-files-output
46 '
47
48 test_expect_success FILEMODE 'mode update (no index)' '
@@ -60,7 +61,8 @@ test_expect_success FILEMODE 'mode update (with index)' '
61 test_expect_success FILEMODE 'mode update (index only)' '
62 git reset --hard &&
63 git apply --cached patch-1.txt &&
63 - git ls-files -s file | grep "^100755"
64 + git ls-files -s file >ls-files-output &&
65 + test_grep "^100755" ls-files-output
66 '
67
68 test_expect_success FILEMODE 'empty mode is rejected' '