t8005: avoid grep on non-ASCII data

GNU grep 2.23 detects the input used in this test as binary data so it does not work for extracting lines from a file. We could add the "-a" option to force grep to treat the input as text, but not all implementations support that. Instead, use sed to extract the desired lines since it will always treat its input as text. While touching these lines, modernize the test style to avoid hiding the exit status of "git blame" and remove a space following a redirection operator. Also swap the order of the expected and actual output files given to test_cmp; we compare expect and actual to show how actual output differs from what is expected. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Keeping committed Feb 21, 2016 at 17:32 UTC 0be43dedbc03139b9d9d0bc71deefc4d7f47296d
1 file changed +16 -12
t/t8005-blame-i18n.sh
+16 -12
@@ -33,11 +33,15 @@ author $SJIS_NAME
33 summary $SJIS_MSG
34 EOF
35
36 +filter_author_summary () {
37 + sed -n -e '/^author /p' -e '/^summary /p' "$@"
38 +}
39 +
40 test_expect_success !MINGW \
41 'blame respects i18n.commitencoding' '
38 - git blame --incremental file | \
39 - egrep "^(author|summary) " > actual &&
40 - test_cmp actual expected
42 + git blame --incremental file >output &&
43 + filter_author_summary output >actual &&
44 + test_cmp expected actual
45 '
46
47 cat >expected <<EOF
@@ -52,9 +56,9 @@ EOF
56 test_expect_success !MINGW \
57 'blame respects i18n.logoutputencoding' '
58 git config i18n.logoutputencoding eucJP &&
55 - git blame --incremental file | \
56 - egrep "^(author|summary) " > actual &&
57 - test_cmp actual expected
59 + git blame --incremental file >output &&
60 + filter_author_summary output >actual &&
61 + test_cmp expected actual
62 '
63
64 cat >expected <<EOF
@@ -68,9 +72,9 @@ EOF
72
73 test_expect_success !MINGW \
74 'blame respects --encoding=UTF-8' '
71 - git blame --incremental --encoding=UTF-8 file | \
72 - egrep "^(author|summary) " > actual &&
73 - test_cmp actual expected
75 + git blame --incremental --encoding=UTF-8 file >output &&
76 + filter_author_summary output >actual &&
77 + test_cmp expected actual
78 '
79
80 cat >expected <<EOF
@@ -84,9 +88,9 @@ EOF
88
89 test_expect_success !MINGW \
90 'blame respects --encoding=none' '
87 - git blame --incremental --encoding=none file | \
88 - egrep "^(author|summary) " > actual &&
89 - test_cmp actual expected
91 + git blame --incremental --encoding=none file >output &&
92 + filter_author_summary output >actual &&
93 + test_cmp expected actual
94 '
95
96 test_done