7fecfe98d2a9db0e0a602166ea944e5be8f4b7a4
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='i18n settings and format-patch | am pipe'
7
8. ./test-lib.sh
9
10test_expect_success setup '
11 git-repo-config i18n.commitencoding UTF-8 &&
12
13 # use UTF-8 in author and committer name to match the
14 # i18n.commitencoding settings
15 . ../t3901-utf8.txt &&
16
17 test_tick &&
18 echo "$GIT_AUTHOR_NAME" >mine &&
19 git add mine &&
20 git commit -s -m "Initial commit" &&
21
22 test_tick &&
23 echo Hello world >mine &&
24 git add mine &&
25 git commit -s -m "Second on main" &&
26
27 # the first commit on the side branch is UTF-8
28 test_tick &&
29 git checkout -b side master^ &&
30 echo Another file >yours &&
31 git add yours &&
32 git commit -s -m "Second on side" &&
33
34 # the second one on the side branch is ISO-8859-1
35 git-repo-config i18n.commitencoding ISO-8859-1 &&
36 # use author and committer name in ISO-8859-1 to match it.
37 . ../t3901-8859-1.txt &&
38 test_tick &&
39 echo Yet another >theirs &&
40 git add theirs &&
41 git commit -s -m "Third on side" &&
42
43 # Back to default
44 git-repo-config i18n.commitencoding UTF-8
45'
46
47test_expect_success 'format-patch output (ISO-8859-1)' '
48 git-repo-config i18n.logoutputencoding ISO-8859-1 &&
49
50 git format-patch --stdout master..HEAD^ >out-l1 &&
51 git format-patch --stdout HEAD^ >out-l2 &&
52 grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 &&
53 grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l1 &&
54 grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 &&
55 grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l2
56'
57
58test_expect_success 'format-patch output (UTF-8)' '
59 git repo-config i18n.logoutputencoding UTF-8 &&
60
61 git format-patch --stdout master..HEAD^ >out-u1 &&
62 git format-patch --stdout HEAD^ >out-u2 &&
63 grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&
64 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u1 &&
65 grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
66 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u2
67'
68
69test_expect_success 'rebase (UTF-8)' '
70 # We want the result of rebase in UTF-8
71 git-repo-config i18n.commitencoding UTF-8 &&
72
73 # The test is about logoutputencoding not affecting the
74 # final outcome -- it is used internally to generate the
75 # patch and the log.
76
77 git repo-config i18n.logoutputencoding UTF-8 &&
78
79 # The result will be committed by GIT_COMMITTER_NAME --
80 # we want UTF-8 encoded name.
81 . ../t3901-utf8.txt &&
82 git checkout -b test &&
83 git-rebase master &&
84
85 # Check the results.
86 git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
87 git format-patch --stdout HEAD^ >out-r2 &&
88 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
89 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2
90
91 ! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
92 ! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
93'
94
95test_expect_success 'rebase (ISO-8859-1)' '
96 git-repo-config i18n.commitencoding UTF-8 &&
97 git repo-config i18n.logoutputencoding ISO-8859-1 &&
98 . ../t3901-utf8.txt &&
99
100 git reset --hard side &&
101 git-rebase master &&
102
103 git repo-config i18n.logoutputencoding UTF-8 &&
104 git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
105 git format-patch --stdout HEAD^ >out-r2 &&
106 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
107 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&
108
109 ! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
110 ! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
111'
112
113test_expect_success 'rebase (ISO-8859-1)' '
114 # In this test we want ISO-8859-1 encoded commits as the result
115 git-repo-config i18n.commitencoding ISO-8859-1 &&
116 git repo-config i18n.logoutputencoding ISO-8859-1 &&
117 . ../t3901-8859-1.txt &&
118
119 git reset --hard side &&
120 git-rebase master &&
121
122 # Make sure characters are not corrupted.
123 git repo-config i18n.logoutputencoding UTF-8 &&
124 git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
125 git format-patch --stdout HEAD^ >out-r2 &&
126 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
127 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&
128
129 git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
130 git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
131'
132
133test_expect_success 'rebase (UTF-8)' '
134 # This is pathological -- use UTF-8 as intermediate form
135 # to get ISO-8859-1 results.
136 git-repo-config i18n.commitencoding ISO-8859-1 &&
137 git repo-config i18n.logoutputencoding UTF-8 &&
138 . ../t3901-8859-1.txt &&
139
140 git reset --hard side &&
141 git-rebase master &&
142
143 # Make sure characters are not corrupted.
144 git repo-config i18n.logoutputencoding UTF-8 &&
145 git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&
146 git format-patch --stdout HEAD^ >out-r2 &&
147 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&
148 grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&
149
150 git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
151 git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
152'
153
154test_done