Code

t3901: test "format-patch | am" pipe with i18n
[git.git] / t / t3901-i18n-patch.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Junio C Hamano
4 #
6 test_description='i18n settings and format-patch | am pipe'
8 . ./test-lib.sh
10 test_expect_success setup '
11         git-repo-config i18n.commitencoding UTF-8 &&
13         # use UTF-8 in author and committer name to match the
14         # i18n.commitencoding settings
15         . ../t3901-utf8.txt &&
17         test_tick &&
18         echo "$GIT_AUTHOR_NAME" >mine &&
19         git add mine &&
20         git commit -s -m "Initial commit" &&
22         test_tick &&
23         echo Hello world >mine &&
24         git add mine &&
25         git commit -s -m "Second on main" &&
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" &&
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" &&
43         # Back to default
44         git-repo-config i18n.commitencoding UTF-8
45 '
47 test_expect_success 'format-patch output (ISO-8859-1)' '
48         git-repo-config i18n.logoutputencoding ISO-8859-1 &&
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 '
58 test_expect_success 'format-patch output (UTF-8)' '
59         git repo-config i18n.logoutputencoding UTF-8 &&
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 '
69 test_expect_success 'rebase (UTF-8)' '
70         # We want the result of rebase in UTF-8
71         git-repo-config i18n.commitencoding UTF-8 &&
73         # The test is about logoutputencoding not affecting the
74         # final outcome -- it is used internally to generate the
75         # patch and the log.
77         git repo-config i18n.logoutputencoding UTF-8 &&
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 &&
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
91         ! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
92         ! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
93 '
95 test_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 &&
100         git reset --hard side &&
101         git-rebase master &&
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 &&
109         ! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
110         ! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
113 test_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 &&
119         git reset --hard side &&
120         git-rebase master &&
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 &&
129         git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
130         git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
133 test_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 &&
140         git reset --hard side &&
141         git-rebase master &&
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 &&
150         git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&
151         git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"
154 test_done