]>
Commit | Line | Data |
---|---|---|
04deccda JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='test log with i18n features' | |
4e2443b1 | 4 | . ./lib-gettext.sh |
04deccda JK |
5 | |
6 | # two forms of é | |
7 | utf8_e=$(printf '\303\251') | |
8 | latin1_e=$(printf '\351') | |
9 | ||
4e2443b1 ÆAB |
10 | # invalid UTF-8 |
11 | invalid_e=$(printf '\303\50)') # ")" at end to close opening "(" | |
12 | ||
04deccda JK |
13 | test_expect_success 'create commits in different encodings' ' |
14 | test_tick && | |
15 | cat >msg <<-EOF && | |
16 | utf8 | |
17 | ||
18 | t${utf8_e}st | |
19 | EOF | |
20 | git add msg && | |
21 | git -c i18n.commitencoding=utf8 commit -F msg && | |
22 | cat >msg <<-EOF && | |
23 | latin1 | |
24 | ||
25 | t${latin1_e}st | |
26 | EOF | |
27 | git add msg && | |
28 | git -c i18n.commitencoding=ISO-8859-1 commit -F msg | |
29 | ' | |
30 | ||
31 | test_expect_success 'log --grep searches in log output encoding (utf8)' ' | |
32 | cat >expect <<-\EOF && | |
33 | latin1 | |
34 | utf8 | |
35 | EOF | |
36 | git log --encoding=utf8 --format=%s --grep=$utf8_e >actual && | |
37 | test_cmp expect actual | |
38 | ' | |
39 | ||
f57a8715 | 40 | test_expect_success !MINGW 'log --grep searches in log output encoding (latin1)' ' |
04deccda JK |
41 | cat >expect <<-\EOF && |
42 | latin1 | |
43 | utf8 | |
44 | EOF | |
45 | git log --encoding=ISO-8859-1 --format=%s --grep=$latin1_e >actual && | |
46 | test_cmp expect actual | |
47 | ' | |
48 | ||
f57a8715 | 49 | test_expect_success !MINGW 'log --grep does not find non-reencoded values (utf8)' ' |
04deccda | 50 | git log --encoding=utf8 --format=%s --grep=$latin1_e >actual && |
d3c6751b | 51 | test_must_be_empty actual |
04deccda JK |
52 | ' |
53 | ||
b14cf112 | 54 | test_expect_success !MINGW 'log --grep does not find non-reencoded values (latin1)' ' |
04deccda | 55 | git log --encoding=ISO-8859-1 --format=%s --grep=$utf8_e >actual && |
d3c6751b | 56 | test_must_be_empty actual |
04deccda JK |
57 | ' |
58 | ||
4e2443b1 ÆAB |
59 | for engine in fixed basic extended perl |
60 | do | |
61 | prereq= | |
4e2443b1 ÆAB |
62 | if test $engine = "perl" |
63 | then | |
4e2443b1 ÆAB |
64 | prereq="PCRE" |
65 | else | |
66 | prereq="" | |
67 | fi | |
68 | force_regex= | |
69 | if test $engine != "fixed" | |
70 | then | |
71 | force_regex=.* | |
72 | fi | |
b14cf112 | 73 | test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not find non-reencoded values (latin1 + locale)" " |
4e2443b1 ÆAB |
74 | cat >expect <<-\EOF && |
75 | latin1 | |
76 | utf8 | |
77 | EOF | |
78 | LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$latin1_e\" >actual && | |
79 | test_cmp expect actual | |
80 | " | |
81 | ||
b14cf112 | 82 | test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not find non-reencoded values (latin1 + locale)" " |
4e2443b1 ÆAB |
83 | LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$utf8_e\" >actual && |
84 | test_must_be_empty actual | |
85 | " | |
86 | ||
b14cf112 | 87 | test_expect_success !MINGW,GETTEXT_LOCALE,$prereq "-c grep.patternType=$engine log --grep does not die on invalid UTF-8 value (latin1 + locale + invalid needle)" " |
4e2443b1 ÆAB |
88 | LC_ALL=\"$is_IS_locale\" git -c grep.patternType=$engine log --encoding=ISO-8859-1 --format=%s --grep=\"$force_regex$invalid_e\" >actual && |
89 | test_must_be_empty actual | |
90 | " | |
91 | done | |
92 | ||
04deccda | 93 | test_done |