Skip to content

Commit 0be43de

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a2558fb commit 0be43de

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

t/t8005-blame-i18n.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ author $SJIS_NAME
3333
summary $SJIS_MSG
3434
EOF
3535

36+
filter_author_summary () {
37+
sed -n -e '/^author /p' -e '/^summary /p' "$@"
38+
}
39+
3640
test_expect_success !MINGW \
3741
'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
4145
'
4246

4347
cat >expected <<EOF
@@ -52,9 +56,9 @@ EOF
5256
test_expect_success !MINGW \
5357
'blame respects i18n.logoutputencoding' '
5458
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
5862
'
5963

6064
cat >expected <<EOF
@@ -68,9 +72,9 @@ EOF
6872

6973
test_expect_success !MINGW \
7074
'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
7478
'
7579

7680
cat >expected <<EOF
@@ -84,9 +88,9 @@ EOF
8488

8589
test_expect_success !MINGW \
8690
'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
9094
'
9195

9296
test_done

0 commit comments

Comments
 (0)