3 test_description
='.mailmap configurations'
9 s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
10 s/$_x05[0-9a-f][0-9a-f]/OBJI/g
11 s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
15 test_expect_success setup
'
19 git commit -m initial &&
23 git commit --author "nick1 <bugs@company.xx>" -m second
35 test_expect_success
'No mailmap' '
36 git shortlog HEAD >actual &&
37 test_cmp expect actual
49 test_expect_success
'default .mailmap' '
50 echo "Repo Guy <author@example.com>" > .mailmap &&
51 git shortlog HEAD >actual &&
52 test_cmp expect actual
55 # Using a mailmap file in a subdirectory of the repo here, but
56 # could just as well have been a file outside of the repository
65 test_expect_success
'mailmap.file set' '
66 mkdir -p internal_mailmap &&
67 echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
68 git config mailmap.file internal_mailmap/.mailmap &&
69 git shortlog HEAD >actual &&
70 test_cmp expect actual
81 test_expect_success
'mailmap.file override' '
82 echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap &&
83 git config mailmap.file internal_mailmap/.mailmap &&
84 git shortlog HEAD >actual &&
85 test_cmp expect actual
97 test_expect_success
'mailmap.file non-existent' '
98 rm internal_mailmap/.mailmap &&
99 rmdir internal_mailmap &&
100 git shortlog HEAD >actual &&
101 test_cmp expect actual
113 test_expect_success
'name entry after email entry' '
114 mkdir -p internal_mailmap &&
115 echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
116 echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap &&
117 git shortlog HEAD >actual &&
118 test_cmp expect actual
130 test_expect_success
'name entry after email entry, case-insensitive' '
131 mkdir -p internal_mailmap &&
132 echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
133 echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap &&
134 git shortlog HEAD >actual &&
135 test_cmp expect actual
146 test_expect_success
'No mailmap files, but configured' '
147 rm -f .mailmap internal_mailmap/.mailmap &&
148 git shortlog HEAD >actual &&
149 test_cmp expect actual
152 test_expect_success
'setup mailmap blob tests' '
153 git checkout -b map &&
154 test_when_finished "git checkout master" &&
155 cat >just-bugs <<-\EOF &&
156 Blob Guy <bugs@company.xx>
159 Blob Guy <author@example.com>
160 Blob Guy <bugs@company.xx>
162 git add just-bugs both &&
163 git commit -m "my mailmaps" &&
164 echo "Repo Guy <author@example.com>" >.mailmap &&
165 echo "Internal Guy <author@example.com>" >internal.map
168 test_expect_success
'mailmap.blob set' '
169 cat >expect <<-\EOF &&
177 git -c mailmap.blob=map:just-bugs shortlog HEAD >actual &&
178 test_cmp expect actual
181 test_expect_success
'mailmap.blob overrides .mailmap' '
182 cat >expect <<-\EOF &&
188 git -c mailmap.blob=map:both shortlog HEAD >actual &&
189 test_cmp expect actual
192 test_expect_success
'mailmap.file overrides mailmap.blob' '
193 cat >expect <<-\EOF &&
202 -c mailmap.blob=map:both \
203 -c mailmap.file=internal.map \
204 shortlog HEAD >actual &&
205 test_cmp expect actual
208 test_expect_success
'mailmap.blob can be missing' '
209 cat >expect <<-\EOF &&
217 git -c mailmap.blob=map:nonexistent shortlog HEAD >actual &&
218 test_cmp expect actual
221 test_expect_success
'mailmap.blob defaults to off in non-bare repo' '
225 test_commit one .mailmap "Fake Name <author@example.com>" &&
226 echo " 1 Fake Name" >expect &&
227 git shortlog -ns HEAD >actual &&
228 test_cmp expect actual &&
230 echo " 1 A U Thor" >expect &&
231 git shortlog -ns HEAD >actual &&
232 test_cmp expect actual
236 test_expect_success
'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
237 git clone --bare non-bare bare &&
240 echo " 1 Fake Name" >expect &&
241 git shortlog -ns HEAD >actual &&
242 test_cmp expect actual
246 test_expect_success
'cleanup after mailmap.blob tests' '
250 test_expect_success
'single-character name' '
251 echo " 1 A <author@example.com>" >expect &&
252 echo " 1 nick1 <bugs@company.xx>" >>expect &&
253 echo "A <author@example.com>" >.mailmap &&
254 test_when_finished "rm .mailmap" &&
255 git shortlog -es HEAD >actual &&
256 test_cmp expect actual
259 # Extended mailmap configurations should give us the following output for shortlog
261 A U Thor
<author@example.com
> (1):
264 CTO
<cto@company.xx
> (1):
267 Other Author
<other@author.xx
> (2):
271 Santa Claus
<santa.claus@northpole.xx
> (2):
275 Some Dude
<some@dude.xx
> (1):
280 test_expect_success
'Shortlog output (complex mapping)' '
284 git commit --author "nick2 <bugs@company.xx>" -m third &&
289 git commit --author "nick2 <nick2@company.xx>" -m fourth &&
294 git commit --author "santa <me@company.xx>" -m fifth &&
299 git commit --author "claus <me@company.xx>" -m sixth &&
304 git commit --author "CTO <cto@coompany.xx>" -m seventh &&
306 mkdir -p internal_mailmap &&
307 echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
308 echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
309 echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
310 echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
311 echo "Other Author <other@author.xx> <nick2@company.xx>" >> internal_mailmap/.mailmap &&
312 echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
313 echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
315 git shortlog -e HEAD >actual &&
316 test_cmp expect actual
320 # git log with --pretty format which uses the name and email mailmap placemarkers
322 Author CTO
<cto@coompany.xx
> maps to CTO
<cto@company.xx
>
323 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
325 Author claus
<me@company.xx
> maps to Santa Claus
<santa.claus@northpole.xx
>
326 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
328 Author santa
<me@company.xx
> maps to Santa Claus
<santa.claus@northpole.xx
>
329 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
331 Author nick2
<nick2@company.xx
> maps to Other Author
<other@author.xx
>
332 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
334 Author nick2
<bugs@company.xx
> maps to Other Author
<other@author.xx
>
335 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
337 Author nick1
<bugs@company.xx
> maps to Some Dude
<some@dude.xx
>
338 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
340 Author A U Thor
<author@example.com
> maps to A U Thor
<author@example.com
>
341 Committer C O Mitter
<committer@example.com
> maps to Committed
<committer@example.com
>
344 test_expect_success
'Log output (complex mapping)' '
345 git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
346 test_cmp expect actual
350 Author
: CTO
<cto@company.xx
>
351 Author
: Santa Claus
<santa.claus@northpole.xx
>
352 Author
: Santa Claus
<santa.claus@northpole.xx
>
353 Author
: Other Author
<other@author.xx
>
354 Author
: Other Author
<other@author.xx
>
355 Author
: Some Dude
<some@dude.xx
>
356 Author
: A U Thor
<author@example.com
>
359 test_expect_success
'Log output with --use-mailmap' '
360 git log --use-mailmap | grep Author >actual &&
361 test_cmp expect actual
365 Author
: CTO
<cto@company.xx
>
366 Author
: Santa Claus
<santa.claus@northpole.xx
>
367 Author
: Santa Claus
<santa.claus@northpole.xx
>
368 Author
: Other Author
<other@author.xx
>
369 Author
: Other Author
<other@author.xx
>
370 Author
: Some Dude
<some@dude.xx
>
371 Author
: A U Thor
<author@example.com
>
374 test_expect_success
'Log output with log.mailmap' '
375 git -c log.mailmap=True log | grep Author >actual &&
376 test_cmp expect actual
380 Author
: Santa Claus
<santa.claus@northpole.xx
>
381 Author
: Santa Claus
<santa.claus@northpole.xx
>
384 test_expect_success
'Grep author with --use-mailmap' '
385 git log --use-mailmap --author Santa | grep Author >actual &&
386 test_cmp expect actual
389 Author
: Santa Claus
<santa.claus@northpole.xx
>
390 Author
: Santa Claus
<santa.claus@northpole.xx
>
393 test_expect_success
'Grep author with log.mailmap' '
394 git -c log.mailmap=True log --author Santa | grep Author >actual &&
395 test_cmp expect actual
400 test_expect_success
'Only grep replaced author with --use-mailmap' '
401 git log --use-mailmap --author "<cto@coompany.xx>" >actual &&
402 test_cmp expect actual
407 ^OBJI
(A U Thor DATE
1) one
408 OBJID
(Some Dude DATE
2) two
409 OBJID
(Other Author DATE
3) three
410 OBJID
(Other Author DATE
4) four
411 OBJID
(Santa Claus DATE
5) five
412 OBJID
(Santa Claus DATE
6) six
413 OBJID
(CTO DATE
7) seven
415 test_expect_success
'Blame output (complex mapping)' '
416 git blame one >actual &&
417 fuzz_blame actual >actual.fuzz &&
418 test_cmp expect actual.fuzz