mailmap tests: modernize syntax & test idioms

Refactor the mailmap tests to: * Setup "actual" test files in the body of "test_expect_success" * Don't have X of "test_expect_success X Y" be an unquoted string. * Not to carry over test config between tests, and instead use "test_config". * Replace various "echo" a line-at-a-time patterns with here-docs. * Change a case of "log.mailmap=False" to use the lower-case "false". Both work, but this ends up in git-config's boolean parsing and these atypical values are tested for elsewhere. Let's use the lower-case to not draw the reader's attention to this abnormality. * Remove commentary asserting that things work a given way in favor of simply testing for it, i.e. in the case of a .mailmap file outside of the repository. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 12, 2021 at 21:17 UTC e9931ace4f69998b7dfaa52701d4e16e7dd50160
1 file changed +274 -199
t/t4203-mailmap.sh
+274 -199
@@ -12,7 +12,7 @@ fuzz_blame () {
12 " "$@"
13 }
14
15 -test_expect_success setup '
15 +test_expect_success 'setup commits and contacts file' '
16 cat >contacts <<-EOF &&
17 $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
18 nick1 <bugs@company.xx>
@@ -66,128 +66,164 @@ test_expect_success 'check-mailmap bogus contact' '
66 test_must_fail git check-mailmap bogus
67 '
68
69 -cat >expect << EOF
70 -$GIT_AUTHOR_NAME (1):
71 - initial
72 -
73 -nick1 (1):
74 - second
69 +test_expect_success 'No mailmap' '
70 + cat >expect <<-EOF &&
71 + $GIT_AUTHOR_NAME (1):
72 + initial
73
76 -EOF
74 + nick1 (1):
75 + second
76
78 -test_expect_success 'No mailmap' '
77 + EOF
78 git shortlog HEAD >actual &&
79 test_cmp expect actual
80 '
81
83 -cat >expect <<\EOF
84 -Repo Guy (1):
85 - initial
82 +test_expect_success 'setup default .mailmap' '
83 + cat >default.map <<-EOF
84 + Repo Guy <$GIT_AUTHOR_EMAIL>
85 + EOF
86 +'
87 +
88 +test_expect_success 'test default .mailmap' '
89 + test_when_finished "rm .mailmap" &&
90 + cp default.map .mailmap &&
91
87 -nick1 (1):
88 - second
92 + cat >expect <<-\EOF &&
93 + Repo Guy (1):
94 + initial
95
90 -EOF
96 + nick1 (1):
97 + second
98
92 -test_expect_success 'default .mailmap' '
93 - echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap &&
99 + EOF
100 git shortlog HEAD >actual &&
101 test_cmp expect actual
102 '
103
98 -# Using a mailmap file in a subdirectory of the repo here, but
99 -# could just as well have been a file outside of the repository
100 -cat >expect <<\EOF
101 -Internal Guy (1):
102 - second
104 +test_expect_success 'mailmap.file set' '
105 + test_when_finished "rm .mailmap" &&
106 + cp default.map .mailmap &&
107
104 -Repo Guy (1):
105 - initial
108 + test_config mailmap.file internal.map &&
109 + cat >internal.map <<-\EOF &&
110 + Internal Guy <bugs@company.xx>
111 + EOF
112
107 -EOF
108 -test_expect_success 'mailmap.file set' '
109 - mkdir -p internal_mailmap &&
110 - echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
111 - git config mailmap.file internal_mailmap/.mailmap &&
113 + cat >expect <<-\EOF &&
114 + Internal Guy (1):
115 + second
116 +
117 + Repo Guy (1):
118 + initial
119 +
120 + EOF
121 git shortlog HEAD >actual &&
113 - test_cmp expect actual
122 + test_cmp expect actual &&
123 +
124 + # The internal_mailmap/.mailmap file is an a subdirectory, but
125 + # as shown here it can also be outside the repository
126 + test_when_finished "rm -rf sub-repo" &&
127 + git clone . sub-repo &&
128 + (
129 + cd sub-repo &&
130 + cp ../.mailmap . &&
131 + git config mailmap.file ../internal.map &&
132 + git shortlog HEAD >actual &&
133 + test_cmp ../expect actual
134 + )
135 '
136
116 -cat >expect <<\EOF
117 -External Guy (1):
118 - initial
137 +test_expect_success 'mailmap.file override' '
138 + test_config mailmap.file internal.map &&
139 + cat >internal.map <<-EOF &&
140 + Internal Guy <bugs@company.xx>
141 + External Guy <$GIT_AUTHOR_EMAIL>
142 + EOF
143
120 -Internal Guy (1):
121 - second
144 + cat >expect <<-\EOF &&
145 + External Guy (1):
146 + initial
147
123 -EOF
124 -test_expect_success 'mailmap.file override' '
125 - echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap &&
126 - git config mailmap.file internal_mailmap/.mailmap &&
148 + Internal Guy (1):
149 + second
150 +
151 + EOF
152 git shortlog HEAD >actual &&
153 test_cmp expect actual
154 '
155
131 -cat >expect <<\EOF
132 -Repo Guy (1):
133 - initial
156 +test_expect_success 'mailmap.file non-existent' '
157 + test_when_finished "rm .mailmap" &&
158 + cp default.map .mailmap &&
159
135 -nick1 (1):
136 - second
160 + cat >expect <<-\EOF &&
161 + Repo Guy (1):
162 + initial
163
138 -EOF
164 + nick1 (1):
165 + second
166
140 -test_expect_success 'mailmap.file non-existent' '
141 - rm internal_mailmap/.mailmap &&
142 - rmdir internal_mailmap &&
167 + EOF
168 git shortlog HEAD >actual &&
169 test_cmp expect actual
170 '
171
147 -cat >expect <<\EOF
148 -Internal Guy (1):
149 - second
172 +test_expect_success 'name entry after email entry' '
173 + test_when_finished "rm .mailmap" &&
174 + cp default.map .mailmap &&
175
151 -Repo Guy (1):
152 - initial
176 + test_config mailmap.file internal.map &&
177 + cat >internal.map <<-\EOF &&
178 + <bugs@company.xy> <bugs@company.xx>
179 + Internal Guy <bugs@company.xx>
180 + EOF
181
154 -EOF
182 + cat >expect <<-\EOF &&
183 + Internal Guy (1):
184 + second
185 +
186 + Repo Guy (1):
187 + initial
188 +
189 + EOF
190
156 -test_expect_success 'name entry after email entry' '
157 - mkdir -p internal_mailmap &&
158 - echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
159 - echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap &&
191 git shortlog HEAD >actual &&
192 test_cmp expect actual
193 '
194
164 -cat >expect <<\EOF
165 -Internal Guy (1):
166 - second
195 +test_expect_success 'name entry after email entry, case-insensitive' '
196 + test_when_finished "rm .mailmap" &&
197 + cp default.map .mailmap &&
198
168 -Repo Guy (1):
169 - initial
199 + test_config mailmap.file internal.map &&
200 + cat >internal.map <<-\EOF &&
201 + <bugs@company.xy> <bugs@company.xx>
202 + Internal Guy <BUGS@Company.xx>
203 + EOF
204
171 -EOF
205 + cat >expect <<-\EOF &&
206 + Internal Guy (1):
207 + second
208 +
209 + Repo Guy (1):
210 + initial
211 +
212 + EOF
213
173 -test_expect_success 'name entry after email entry, case-insensitive' '
174 - mkdir -p internal_mailmap &&
175 - echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
176 - echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap &&
214 git shortlog HEAD >actual &&
215 test_cmp expect actual
216 '
217
181 -cat >expect << EOF
182 -$GIT_AUTHOR_NAME (1):
183 - initial
218 +test_expect_success 'No mailmap files, but configured' '
219 + cat >expect <<-EOF &&
220 + $GIT_AUTHOR_NAME (1):
221 + initial
222
185 -nick1 (1):
186 - second
223 + nick1 (1):
224 + second
225
188 -EOF
189 -test_expect_success 'No mailmap files, but configured' '
190 - rm -f .mailmap internal_mailmap/.mailmap &&
226 + EOF
227 git shortlog HEAD >actual &&
228 test_cmp expect actual
229 '
@@ -205,11 +241,16 @@ test_expect_success 'setup mailmap blob tests' '
241 printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline &&
242 git add just-bugs both no-newline &&
243 git commit -m "my mailmaps" &&
208 - echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap &&
209 - echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map
244 +
245 + cat >internal.map <<-EOF
246 + Internal Guy <$GIT_AUTHOR_EMAIL>
247 + EOF
248 '
249
250 test_expect_success 'mailmap.blob set' '
251 + test_when_finished "rm .mailmap" &&
252 + cp default.map .mailmap &&
253 +
254 cat >expect <<-\EOF &&
255 Blob Guy (1):
256 second
@@ -223,6 +264,9 @@ test_expect_success 'mailmap.blob set' '
264 '
265
266 test_expect_success 'mailmap.blob overrides .mailmap' '
267 + test_when_finished "rm .mailmap" &&
268 + cp default.map .mailmap &&
269 +
270 cat >expect <<-\EOF &&
271 Blob Guy (2):
272 initial
@@ -250,6 +294,9 @@ test_expect_success 'mailmap.file overrides mailmap.blob' '
294 '
295
296 test_expect_success 'mailmap.blob can be missing' '
297 + test_when_finished "rm .mailmap" &&
298 + cp default.map .mailmap &&
299 +
300 cat >expect <<-\EOF &&
301 Repo Guy (1):
302 initial
@@ -267,11 +314,15 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
314 (
315 cd non-bare &&
316 test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" &&
270 - echo " 1 Fake Name" >expect &&
317 + cat >expect <<-\EOF &&
318 + 1 Fake Name
319 + EOF
320 git shortlog -ns HEAD >actual &&
321 test_cmp expect actual &&
322 rm .mailmap &&
274 - echo " 1 $GIT_AUTHOR_NAME" >expect &&
323 + cat >expect <<-EOF &&
324 + 1 $GIT_AUTHOR_NAME
325 + EOF
326 git shortlog -ns HEAD >actual &&
327 test_cmp expect actual
328 )
@@ -281,7 +332,9 @@ test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
332 git clone --bare non-bare bare &&
333 (
334 cd bare &&
284 - echo " 1 Fake Name" >expect &&
335 + cat >expect <<-\EOF &&
336 + 1 Fake Name
337 + EOF
338 git shortlog -ns HEAD >actual &&
339 test_cmp expect actual
340 )
@@ -300,50 +353,46 @@ test_expect_success 'mailmap.blob can handle blobs without trailing newline' '
353 test_cmp expect actual
354 '
355
303 -test_expect_success 'cleanup after mailmap.blob tests' '
304 - rm -f .mailmap
305 -'
306 -
356 test_expect_success 'single-character name' '
308 - echo " 1 A <$GIT_AUTHOR_EMAIL>" >expect &&
309 - echo " 1 nick1 <bugs@company.xx>" >>expect &&
310 - echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap &&
357 test_when_finished "rm .mailmap" &&
358 + cat >.mailmap <<-EOF &&
359 + A <$GIT_AUTHOR_EMAIL>
360 + EOF
361 +
362 + cat >expect <<-EOF &&
363 + 1 A <$GIT_AUTHOR_EMAIL>
364 + 1 nick1 <bugs@company.xx>
365 + EOF
366 git shortlog -es HEAD >actual &&
367 test_cmp expect actual
368 '
369
370 test_expect_success 'preserve canonical email case' '
317 - echo " 1 $GIT_AUTHOR_NAME <AUTHOR@example.com>" >expect &&
318 - echo " 1 nick1 <bugs@company.xx>" >>expect &&
319 - echo "<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>" >.mailmap &&
371 test_when_finished "rm .mailmap" &&
372 + cat >.mailmap <<-EOF &&
373 + <AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>
374 + EOF
375 +
376 + cat >expect <<-EOF &&
377 + 1 $GIT_AUTHOR_NAME <AUTHOR@example.com>
378 + 1 nick1 <bugs@company.xx>
379 + EOF
380 git shortlog -es HEAD >actual &&
381 test_cmp expect actual
382 '
383
325 -# Extended mailmap configurations should give us the following output for shortlog
326 -cat >expect << EOF
327 -$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
328 - initial
329 -
330 -CTO <cto@company.xx> (1):
331 - seventh
332 -
333 -Other Author <other@author.xx> (2):
334 - third
335 - fourth
336 -
337 -Santa Claus <santa.claus@northpole.xx> (2):
338 - fifth
339 - sixth
340 -
341 -Some Dude <some@dude.xx> (1):
342 - second
343 -
344 -EOF
345 -
384 test_expect_success 'Shortlog output (complex mapping)' '
385 + test_config mailmap.file complex.map &&
386 + cat >complex.map <<-EOF &&
387 + Committed <$GIT_COMMITTER_EMAIL>
388 + <cto@company.xx> <cto@coompany.xx>
389 + Some Dude <some@dude.xx> nick1 <bugs@company.xx>
390 + Other Author <other@author.xx> nick2 <bugs@company.xx>
391 + Other Author <other@author.xx> <nick2@company.xx>
392 + Santa Claus <santa.claus@northpole.xx> <me@company.xx>
393 + Santa Claus <santa.claus@northpole.xx> <me@company.xx>
394 + EOF
395 +
396 echo three >>one &&
397 git add one &&
398 test_tick &&
@@ -369,103 +418,119 @@ test_expect_success 'Shortlog output (complex mapping)' '
418 test_tick &&
419 git commit --author "CTO <cto@coompany.xx>" -m seventh &&
420
372 - mkdir -p internal_mailmap &&
373 - echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
374 - echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
375 - echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
376 - echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
377 - echo "Other Author <other@author.xx> <nick2@company.xx>" >> internal_mailmap/.mailmap &&
378 - echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
379 - echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
421 + cat >expect <<-EOF &&
422 + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
423 + initial
424 +
425 + CTO <cto@company.xx> (1):
426 + seventh
427 +
428 + Other Author <other@author.xx> (2):
429 + third
430 + fourth
431 +
432 + Santa Claus <santa.claus@northpole.xx> (2):
433 + fifth
434 + sixth
435 +
436 + Some Dude <some@dude.xx> (1):
437 + second
438 +
439 + EOF
440
441 git shortlog -e HEAD >actual &&
442 test_cmp expect actual
443
444 '
445
386 -# git log with --pretty format which uses the name and email mailmap placemarkers
387 -cat >expect << EOF
388 -Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
389 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
446 +test_expect_success 'Log output (complex mapping)' '
447 + test_config mailmap.file complex.map &&
448
391 -Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
392 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
449 + cat >expect <<-EOF &&
450 + Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
451 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
452
394 -Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
395 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
453 + Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
454 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
455
397 -Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
398 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
456 + Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
457 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
458
400 -Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
401 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
459 + Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
460 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
461
403 -Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
404 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
462 + Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
463 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
464
406 -Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
407 -Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
408 -EOF
465 + Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
466 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
467 +
468 + Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
469 + Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
470 + EOF
471
410 -test_expect_success 'Log output (complex mapping)' '
472 git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
473 test_cmp expect actual
474 '
475
415 -cat >expect << EOF
416 -Author email cto@coompany.xx has local-part cto
417 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
476 +test_expect_success 'Log output (local-part email address)' '
477 + cat >expect <<-EOF &&
478 + Author email cto@coompany.xx has local-part cto
479 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
480
419 -Author email me@company.xx has local-part me
420 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
481 + Author email me@company.xx has local-part me
482 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
483
422 -Author email me@company.xx has local-part me
423 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
484 + Author email me@company.xx has local-part me
485 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
486
425 -Author email nick2@company.xx has local-part nick2
426 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
487 + Author email nick2@company.xx has local-part nick2
488 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
489
428 -Author email bugs@company.xx has local-part bugs
429 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
490 + Author email bugs@company.xx has local-part bugs
491 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
492
431 -Author email bugs@company.xx has local-part bugs
432 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
493 + Author email bugs@company.xx has local-part bugs
494 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
495
434 -Author email author@example.com has local-part author
435 -Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
436 -EOF
496 + Author email author@example.com has local-part author
497 + Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
498 + EOF
499
438 -test_expect_success 'Log output (local-part email address)' '
500 git log --pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n" >actual &&
501 test_cmp expect actual
502 '
503
443 -cat >expect << EOF
444 -Author: CTO <cto@company.xx>
445 -Author: Santa Claus <santa.claus@northpole.xx>
446 -Author: Santa Claus <santa.claus@northpole.xx>
447 -Author: Other Author <other@author.xx>
448 -Author: Other Author <other@author.xx>
449 -Author: Some Dude <some@dude.xx>
450 -Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
451 -EOF
452 -
504 test_expect_success 'Log output with --use-mailmap' '
505 + test_config mailmap.file complex.map &&
506 +
507 + cat >expect <<-EOF &&
508 + Author: CTO <cto@company.xx>
509 + Author: Santa Claus <santa.claus@northpole.xx>
510 + Author: Santa Claus <santa.claus@northpole.xx>
511 + Author: Other Author <other@author.xx>
512 + Author: Other Author <other@author.xx>
513 + Author: Some Dude <some@dude.xx>
514 + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
515 + EOF
516 +
517 git log --use-mailmap | grep Author >actual &&
518 test_cmp expect actual
519 '
520
458 -cat >expect << EOF
459 -Author: CTO <cto@company.xx>
460 -Author: Santa Claus <santa.claus@northpole.xx>
461 -Author: Santa Claus <santa.claus@northpole.xx>
462 -Author: Other Author <other@author.xx>
463 -Author: Other Author <other@author.xx>
464 -Author: Some Dude <some@dude.xx>
465 -Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
466 -EOF
467 -
521 test_expect_success 'Log output with log.mailmap' '
522 + test_config mailmap.file complex.map &&
523 +
524 + cat >expect <<-EOF &&
525 + Author: CTO <cto@company.xx>
526 + Author: Santa Claus <santa.claus@northpole.xx>
527 + Author: Santa Claus <santa.claus@northpole.xx>
528 + Author: Other Author <other@author.xx>
529 + Author: Other Author <other@author.xx>
530 + Author: Some Dude <some@dude.xx>
531 + Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
532 + EOF
533 +
534 git -c log.mailmap=True log | grep Author >actual &&
535 test_cmp expect actual
536 '
@@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
545 Author: nick1 <bugs@company.xx>
546 Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
547 EOF
483 - git -c log.mailmap=False log | grep Author >actual &&
548 + git -c log.mailmap=false log | grep Author >actual &&
549 test_cmp expect actual
550 '
551
@@ -498,56 +563,66 @@ test_expect_success '--no-use-mailmap disables mailmap' '
563 test_cmp expect actual
564 '
565
501 -cat >expect <<\EOF
502 -Author: Santa Claus <santa.claus@northpole.xx>
503 -Author: Santa Claus <santa.claus@northpole.xx>
504 -EOF
505 -
566 test_expect_success 'Grep author with --use-mailmap' '
567 + test_config mailmap.file complex.map &&
568 +
569 + cat >expect <<-\EOF &&
570 + Author: Santa Claus <santa.claus@northpole.xx>
571 + Author: Santa Claus <santa.claus@northpole.xx>
572 + EOF
573 git log --use-mailmap --author Santa | grep Author >actual &&
574 test_cmp expect actual
575 '
510 -cat >expect <<\EOF
511 -Author: Santa Claus <santa.claus@northpole.xx>
512 -Author: Santa Claus <santa.claus@northpole.xx>
513 -EOF
576
577 test_expect_success 'Grep author with log.mailmap' '
578 + test_config mailmap.file complex.map &&
579 +
580 + cat >expect <<-\EOF &&
581 + Author: Santa Claus <santa.claus@northpole.xx>
582 + Author: Santa Claus <santa.claus@northpole.xx>
583 + EOF
584 +
585 git -c log.mailmap=True log --author Santa | grep Author >actual &&
586 test_cmp expect actual
587 '
588
589 test_expect_success 'log.mailmap is true by default these days' '
590 + test_config mailmap.file complex.map &&
591 git log --author Santa | grep Author >actual &&
592 test_cmp expect actual
593 '
594
595 test_expect_success 'Only grep replaced author with --use-mailmap' '
596 + test_config mailmap.file complex.map &&
597 git log --use-mailmap --author "<cto@coompany.xx>" >actual &&
598 test_must_be_empty actual
599 '
600
530 -# git blame
531 -cat >expect <<EOF
532 -^OBJI ($GIT_AUTHOR_NAME DATE 1) one
533 -OBJID (Some Dude DATE 2) two
534 -OBJID (Other Author DATE 3) three
535 -OBJID (Other Author DATE 4) four
536 -OBJID (Santa Claus DATE 5) five
537 -OBJID (Santa Claus DATE 6) six
538 -OBJID (CTO DATE 7) seven
539 -EOF
601 test_expect_success 'Blame output (complex mapping)' '
602 + test_config mailmap.file complex.map &&
603 +
604 + cat >expect <<-EOF &&
605 + ^OBJI ($GIT_AUTHOR_NAME DATE 1) one
606 + OBJID (Some Dude DATE 2) two
607 + OBJID (Other Author DATE 3) three
608 + OBJID (Other Author DATE 4) four
609 + OBJID (Santa Claus DATE 5) five
610 + OBJID (Santa Claus DATE 6) six
611 + OBJID (CTO DATE 7) seven
612 + EOF
613 +
614 git blame one >actual &&
615 fuzz_blame actual >actual.fuzz &&
616 test_cmp expect actual.fuzz
617 '
618
546 -cat >expect <<\EOF
547 -Some Dude <some@dude.xx>
548 -EOF
549 -
619 test_expect_success 'commit --author honors mailmap' '
620 + test_config mailmap.file complex.map &&
621 +
622 + cat >expect <<-\EOF &&
623 + Some Dude <some@dude.xx>
624 + EOF
625 +
626 test_must_fail git commit --author "nick" --allow-empty -meight &&
627 git commit --author "Some Dude" --allow-empty -meight &&
628 git show --pretty=format:"%an <%ae>%n" >actual &&