3 test_description='test log with i18n features'
7 utf8_e=$(printf '\303\251')
8 latin1_e=$(printf '\351')
11 invalid_e=$(printf '\303\50)') # ")" at end to close opening "("
14 if test_have_prereq GETTEXT_LOCALE &&
15 ! LC_ALL=$is_IS_locale test-tool regex --silent $latin1_e
20 test_expect_success 'create commits in different encodings' '
28 git -c i18n.commitencoding=utf8 commit -F msg &&
35 git -c i18n.commitencoding=ISO-8859-1 commit -F msg
38 test_expect_success 'log --grep searches in log output encoding (utf8)' '
39 cat >expect <<-\EOF &&
43 git log --encoding=utf8 --format=%s --grep=$utf8_e >actual &&
44 test_cmp expect actual
47 test_expect_success !MINGW 'log --grep searches in log output encoding (latin1)' '
48 cat >expect <<-\EOF &&
52 git log --encoding=ISO-8859-1 --format=%s --grep=$latin1_e >actual &&
53 test_cmp expect actual
56 test_expect_success !MINGW 'log --grep does not find non-reencoded values (utf8)' '
57 git log --encoding=utf8 --format=%s --grep=$latin1_e >actual &&
58 test_must_be_empty actual
61 test_expect_success 'log --grep does not find non-reencoded values (latin1)' '
62 git log --encoding=ISO-8859-1 --format=%s --grep=$utf8_e >actual &&
63 test_must_be_empty actual
66 triggers_undefined_behaviour () {
71 if test -n "$have_reg_illseq" &&
72 ! test_have_prereq LIBPCRE2
78 if test -n "$have_reg_illseq"
87 mismatched_git_log () {
90 LC_ALL=$is_IS_locale git log --encoding=ISO-8859-1 --format=%s \
94 for engine in fixed basic extended perl
97 if test $engine = "perl"
102 if test $engine != "fixed"
107 test_expect_success $prereq "config grep.patternType=$engine" "
108 git config grep.patternType $engine
111 test_expect_success GETTEXT_LOCALE,$prereq "log --grep does not find non-reencoded values (latin1 + locale)" "
112 mismatched_git_log '$force_regex$utf8_e' >actual &&
113 test_must_be_empty actual
116 if ! triggers_undefined_behaviour $engine
118 test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "log --grep searches in log output encoding (latin1 + locale)" "
119 cat >expect <<-\EOF &&
123 mismatched_git_log '$force_regex$latin1_e' >actual &&
124 test_cmp expect actual
127 test_expect_success GETTEXT_LOCALE,$prereq "log --grep does not die on invalid UTF-8 value (latin1 + locale + invalid needle)" "
128 mismatched_git_log '$force_regex$invalid_e' >actual &&
129 test_must_be_empty actual