Skip to content

Commit 86325d3

Browse files
rscharfegitster
authored andcommitted
t3920: support CR-eating grep
grep(1) converts CRLF line endings to LF on current MinGW: $ uname -sr MINGW64_NT-10.0-22621 3.3.6-341.x86_64 $ printf 'a\r\n' | hexdump.exe -C 00000000 61 0d 0a |a..| 00000003 $ printf 'a\r\n' | grep . | hexdump.exe -C 00000000 61 0a |a.| 00000002 Create the intended test file by grepping the original file with LF line endings and adding CRs explicitly. The missing CRs went unnoticed because test_cmp on MinGW ignores line endings since 4d715ac (Windows: a test_cmp that is agnostic to random LF <> CRLF conversions, 2013-10-26). Fix this test anyway to avoid depending on that special test_cmp behavior, especially since this is the only test that needs it. Piping the output of grep(1) through append_cr has the side-effect of ignoring its return value. That means we no longer need the explicit "|| true" to support commit messages without a body. Signed-off-by: René Scharfe <[email protected]> Acked-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 500317a commit 86325d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/t3920-crlf-messages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ create_crlf_ref () {
1212
cat >.crlf-orig-$branch.txt &&
1313
cat .crlf-orig-$branch.txt | append_cr >.crlf-message-$branch.txt &&
1414
grep 'Subject' .crlf-orig-$branch.txt | tr '\n' ' ' | sed 's/[ ]*$//' | tr -d '\n' >.crlf-subject-$branch.txt &&
15-
{ grep 'Body' .crlf-message-$branch.txt >.crlf-body-$branch.txt || true; } &&
15+
grep 'Body' .crlf-orig-$branch.txt | append_cr >.crlf-body-$branch.txt &&
1616
LIB_CRLF_BRANCHES="${LIB_CRLF_BRANCHES} ${branch}" &&
1717
test_tick &&
1818
hash=$(git commit-tree HEAD^{tree} -p HEAD -F .crlf-message-${branch}.txt) &&

0 commit comments

Comments
 (0)