3 test_description
='test log with i18n features'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 utf8_e
=$
(printf '\303\251')
10 latin1_e
=$
(printf '\351')
13 invalid_e
=$
(printf '\303\50)') # ")" at end to close opening "("
16 if test_have_prereq GETTEXT_LOCALE
&&
17 ! LC_ALL
=$is_IS_locale test-tool regex
--silent $latin1_e
22 test_expect_success
'create commits in different encodings' '
30 git -c i18n.commitencoding=utf8 commit -F msg &&
37 git -c i18n.commitencoding=ISO-8859-1 commit -F msg
40 test_expect_success
'log --grep searches in log output encoding (utf8)' '
41 cat >expect <<-\EOF &&
45 git log --encoding=utf8 --format=%s --grep=$utf8_e >actual &&
46 test_cmp expect actual
49 test_expect_success
!MINGW
'log --grep searches in log output encoding (latin1)' '
50 cat >expect <<-\EOF &&
54 git log --encoding=ISO-8859-1 --format=%s --grep=$latin1_e >actual &&
55 test_cmp expect actual
58 test_expect_success
!MINGW
'log --grep does not find non-reencoded values (utf8)' '
59 git log --encoding=utf8 --format=%s --grep=$latin1_e >actual &&
60 test_must_be_empty actual
63 test_expect_success
'log --grep does not find non-reencoded values (latin1)' '
64 git log --encoding=ISO-8859-1 --format=%s --grep=$utf8_e >actual &&
65 test_must_be_empty actual
68 triggers_undefined_behaviour
() {
73 if test -n "$have_reg_illseq" &&
74 ! test_have_prereq LIBPCRE2
80 if test -n "$have_reg_illseq"
89 mismatched_git_log
() {
92 LC_ALL
=$is_IS_locale git log
--encoding=ISO-8859-1
--format=%s \
96 for engine
in fixed basic extended perl
99 if test $engine = "perl"
104 if test $engine != "fixed"
109 test_expect_success
$prereq "config grep.patternType=$engine" "
110 git config grep.patternType $engine
113 test_expect_success GETTEXT_LOCALE
,$prereq "log --grep does not find non-reencoded values (latin1 + locale)" "
114 mismatched_git_log '$force_regex$utf8_e' >actual &&
115 test_must_be_empty actual
118 if ! triggers_undefined_behaviour
$engine
120 test_expect_success
!MINGW
,GETTEXT_LOCALE
,$prereq "log --grep searches in log output encoding (latin1 + locale)" "
121 cat >expect <<-\EOF &&
125 mismatched_git_log '$force_regex$latin1_e' >actual &&
126 test_cmp expect actual
129 test_expect_success GETTEXT_LOCALE
,$prereq "log --grep does not die on invalid UTF-8 value (latin1 + locale + invalid needle)" "
130 mismatched_git_log '$force_regex$invalid_e' >actual &&
131 test_must_be_empty actual