]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7812-grep-icase-non-ascii.sh
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / t / t7812-grep-icase-non-ascii.sh
CommitLineData
5c1ebcca
NTND
1#!/bin/sh
2
3test_description='grep icase on non-English locales'
4
5. ./lib-gettext.sh
6
7test_expect_success GETTEXT_LOCALE 'setup' '
8 test_write_lines "TILRAUN: Halló Heimur!" >file &&
9 git add file &&
10 LC_ALL="$is_IS_locale" &&
11 export LC_ALL
12'
13
14test_have_prereq GETTEXT_LOCALE &&
9038531f 15test-tool regex "HALLÓ" "Halló" ICASE &&
5c1ebcca
NTND
16test_set_prereq REGEX_LOCALE
17
18test_expect_success REGEX_LOCALE 'grep literal string, no -F' '
19 git grep -i "TILRAUN: Halló Heimur!" &&
20 git grep -i "TILRAUN: HALLÓ HEIMUR!"
21'
22
3eb585c1 23test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 icase' '
18547aac
NTND
24 git grep --perl-regexp "TILRAUN: H.lló Heimur!" &&
25 git grep --perl-regexp -i "TILRAUN: H.lló Heimur!" &&
26 git grep --perl-regexp -i "TILRAUN: H.LLÓ HEIMUR!"
27'
28
3eb585c1 29test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 string with "+"' '
18547aac
NTND
30 test_write_lines "TILRAUN: Hallóó Heimur!" >file2 &&
31 git add file2 &&
32 git grep -l --perl-regexp "TILRAUN: H.lló+ Heimur!" >actual &&
33 echo file >expected &&
34 echo file2 >>expected &&
35 test_cmp expected actual
36'
37
793dc676 38test_expect_success REGEX_LOCALE 'grep literal string, with -F' '
e01b4dab
ÆAB
39 git grep -i -F "TILRAUN: Halló Heimur!" &&
40 git grep -i -F "TILRAUN: HALLÓ HEIMUR!"
793dc676
NTND
41'
42
43test_expect_success REGEX_LOCALE 'grep string with regex, with -F' '
e01b4dab
ÆAB
44 test_write_lines "TILRAUN: Halló Heimur [abc]!" >file3 &&
45 git add file3 &&
46 git grep -i -F "TILRAUN: Halló Heimur [abc]!" file3
793dc676
NTND
47'
48
b51a9c14
NTND
49test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' '
50 git commit -m first &&
51 git log --format=%f -i -S"TILRAUN: HALLÓ HEIMUR!" >actual &&
52 echo first >expected &&
53 test_cmp expected actual
54'
55
8a599983
ÆAB
56test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data' '
57 printf "\\200\\n" >invalid-0x80 &&
58 echo "ævar" >expected &&
59 cat expected >>invalid-0x80 &&
95ca1f98
ÆAB
60 git add invalid-0x80 &&
61
62 # Test for PCRE2_MATCH_INVALID_UTF bug
63 # https://bugs.exim.org/show_bug.cgi?id=2642
64 printf "\\345Aæ\\n" >invalid-0xe5 &&
65 git add invalid-0xe5
8a599983
ÆAB
66'
67
68test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data' '
69 git grep -h "var" invalid-0x80 >actual &&
70 test_cmp expected actual &&
71 git grep -h "(*NO_JIT)var" invalid-0x80 >actual &&
72 test_cmp expected actual
73'
74
95ca1f98
ÆAB
75test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
76 git grep -h "Aæ" invalid-0xe5 >actual &&
77 test_cmp invalid-0xe5 actual &&
78 git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
79 test_cmp invalid-0xe5 actual
80'
81
8a599983 82test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data' '
870eea81 83 git grep -h "æ" invalid-0x80 >actual &&
8a599983 84 test_cmp expected actual &&
c74b3cbb 85 git grep -h "(*NO_JIT)æ" invalid-0x80 >actual &&
8a599983
ÆAB
86 test_cmp expected actual
87'
88
95ca1f98
ÆAB
89test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
90 git grep -h "Aæ" invalid-0xe5 >actual &&
91 test_cmp invalid-0xe5 actual &&
92 git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
93 test_cmp invalid-0xe5 actual
94'
95
96test_lazy_prereq PCRE2_MATCH_INVALID_UTF '
97 test-tool pcre2-config has-PCRE2_MATCH_INVALID_UTF
98'
99
8a599983
ÆAB
100test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
101 test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
a4fea08b 102 test_might_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual
8a599983
ÆAB
103'
104
95ca1f98
ÆAB
105test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
106 git grep -hi "Æ" invalid-0x80 >actual &&
107 test_cmp expected actual &&
108 git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
109 test_cmp expected actual
110'
111
112test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i (PCRE2 bug #2642)' '
113 git grep -hi "Æ" invalid-0xe5 >actual &&
114 test_cmp invalid-0xe5 actual &&
115 git grep -hi "(*NO_JIT)Æ" invalid-0xe5 >actual &&
116 test_cmp invalid-0xe5 actual &&
117
118 # Only the case of grepping the ASCII part in a way that
119 # relies on -i fails
120 git grep -hi "aÆ" invalid-0xe5 >actual &&
121 test_cmp invalid-0xe5 actual &&
122 git grep -hi "(*NO_JIT)aÆ" invalid-0xe5 >actual &&
123 test_cmp invalid-0xe5 actual
124'
125
dc2c44fb
RS
126test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-literal ASCII from UTF-8' '
127 git grep --perl-regexp -h -o -e ll. file >actual &&
128 echo "lló" >expected &&
129 test_cmp expected actual
130'
131
5c1ebcca 132test_done