Skip to content

Commit 4d93bb4

Browse files
author
Chandra Pratap
committed
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>
1 parent a54a84b commit 4d93bb4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

t/t4129-apply-samemode.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ test_expect_success FILEMODE 'same mode (index only)' '
4141
chmod +x file &&
4242
git add file &&
4343
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
4546
'
4647

4748
test_expect_success FILEMODE 'mode update (no index)' '
@@ -60,7 +61,8 @@ test_expect_success FILEMODE 'mode update (with index)' '
6061
test_expect_success FILEMODE 'mode update (index only)' '
6162
git reset --hard &&
6263
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
6466
'
6567

6668
test_expect_success FILEMODE 'empty mode is rejected' '

0 commit comments

Comments
 (0)