f4f82c02379c7cf80251bb870cbb3b875e142db4
1 #!/bin/sh
3 test_description='.mailmap configurations'
5 . ./test-lib.sh
7 test_expect_success setup '
8 echo one >one &&
9 git add one &&
10 test_tick &&
11 git commit -m initial &&
12 echo two >>one &&
13 git add one &&
14 test_tick &&
15 git commit --author "nick1 <bugs@company.xx>" -m second
16 '
18 cat >expect <<\EOF
19 A U Thor (1):
20 initial
22 nick1 (1):
23 second
25 EOF
27 test_expect_success 'No mailmap' '
28 git shortlog HEAD >actual &&
29 test_cmp expect actual
30 '
32 cat >expect <<\EOF
33 Repo Guy (1):
34 initial
36 nick1 (1):
37 second
39 EOF
41 test_expect_success 'default .mailmap' '
42 echo "Repo Guy <author@example.com>" > .mailmap &&
43 git shortlog HEAD >actual &&
44 test_cmp expect actual
45 '
47 # Using a mailmap file in a subdirectory of the repo here, but
48 # could just as well have been a file outside of the repository
49 cat >expect <<\EOF
50 Internal Guy (1):
51 second
53 Repo Guy (1):
54 initial
56 EOF
57 test_expect_success 'mailmap.file set' '
58 mkdir -p internal_mailmap &&
59 echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
60 git config mailmap.file internal_mailmap/.mailmap &&
61 git shortlog HEAD >actual &&
62 test_cmp expect actual
63 '
65 cat >expect <<\EOF
66 External Guy (1):
67 initial
69 Internal Guy (1):
70 second
72 EOF
73 test_expect_success 'mailmap.file override' '
74 echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap &&
75 git config mailmap.file internal_mailmap/.mailmap &&
76 git shortlog HEAD >actual &&
77 test_cmp expect actual
78 '
80 cat >expect <<\EOF
81 Repo Guy (1):
82 initial
84 nick1 (1):
85 second
87 EOF
89 test_expect_success 'mailmap.file non-existant' '
90 rm internal_mailmap/.mailmap &&
91 rmdir internal_mailmap &&
92 git shortlog HEAD >actual &&
93 test_cmp expect actual
94 '
96 cat >expect <<\EOF
97 Internal Guy (1):
98 second
100 Repo Guy (1):
101 initial
103 EOF
105 test_expect_success 'name entry after email entry' '
106 mkdir -p internal_mailmap &&
107 echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
108 echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap &&
109 git shortlog >actual &&
110 test_cmp expect actual
111 '
113 cat >expect <<\EOF
114 Internal Guy (1):
115 second
117 Repo Guy (1):
118 initial
120 EOF
122 test_expect_success 'name entry after email entry, case-insensitive' '
123 mkdir -p internal_mailmap &&
124 echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
125 echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap &&
126 git shortlog >actual &&
127 test_cmp expect actual
128 '
130 cat >expect <<\EOF
131 A U Thor (1):
132 initial
134 nick1 (1):
135 second
137 EOF
138 test_expect_success 'No mailmap files, but configured' '
139 rm -f .mailmap internal_mailmap/.mailmap &&
140 git shortlog HEAD >actual &&
141 test_cmp expect actual
142 '
144 # Extended mailmap configurations should give us the following output for shortlog
145 cat >expect <<\EOF
146 A U Thor <author@example.com> (1):
147 initial
149 CTO <cto@company.xx> (1):
150 seventh
152 Other Author <other@author.xx> (2):
153 third
154 fourth
156 Santa Claus <santa.claus@northpole.xx> (2):
157 fifth
158 sixth
160 Some Dude <some@dude.xx> (1):
161 second
163 EOF
165 test_expect_success 'Shortlog output (complex mapping)' '
166 echo three >>one &&
167 git add one &&
168 test_tick &&
169 git commit --author "nick2 <bugs@company.xx>" -m third &&
171 echo four >>one &&
172 git add one &&
173 test_tick &&
174 git commit --author "nick2 <nick2@company.xx>" -m fourth &&
176 echo five >>one &&
177 git add one &&
178 test_tick &&
179 git commit --author "santa <me@company.xx>" -m fifth &&
181 echo six >>one &&
182 git add one &&
183 test_tick &&
184 git commit --author "claus <me@company.xx>" -m sixth &&
186 echo seven >>one &&
187 git add one &&
188 test_tick &&
189 git commit --author "CTO <cto@coompany.xx>" -m seventh &&
191 mkdir -p internal_mailmap &&
192 echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
193 echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
194 echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
195 echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
196 echo "Other Author <other@author.xx> <nick2@company.xx>" >> internal_mailmap/.mailmap &&
197 echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
198 echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
200 git shortlog -e HEAD >actual &&
201 test_cmp expect actual
203 '
205 # git log with --pretty format which uses the name and email mailmap placemarkers
206 cat >expect <<\EOF
207 Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
208 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
210 Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
211 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
213 Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
214 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
216 Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
217 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
219 Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
220 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
222 Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
223 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
225 Author A U Thor <author@example.com> maps to A U Thor <author@example.com>
226 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
227 EOF
229 test_expect_success 'Log output (complex mapping)' '
230 git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
231 test_cmp expect actual
232 '
234 # git blame
235 cat >expect <<\EOF
236 ^3a2fdcb (A U Thor 2005-04-07 15:13:13 -0700 1) one
237 7de6f99b (Some Dude 2005-04-07 15:13:13 -0700 2) two
238 5815879d (Other Author 2005-04-07 15:14:13 -0700 3) three
239 ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four
240 5ab6d4fa (Santa Claus 2005-04-07 15:16:13 -0700 5) five
241 38a42d8b (Santa Claus 2005-04-07 15:17:13 -0700 6) six
242 8ddc0386 (CTO 2005-04-07 15:18:13 -0700 7) seven
243 EOF
245 test_expect_success 'Blame output (complex mapping)' '
246 git blame one >actual &&
247 test_cmp expect actual
248 '
250 test_done