Add mailmap.file as configurational option for mailmap location
[git/git.git] / t / t4203-mailmap.sh
1 #!/bin/sh
2
3 test_description='.mailmap configurations'
4
5 . ./test-lib.sh
6
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 git commit --author "nick1 <bugs@company.xx>" -m second
15 '
16
17 cat >expect <<\EOF
18 A U Thor (1):
19 initial
20
21 nick1 (1):
22 second
23
24 EOF
25
26 test_expect_success 'No mailmap' '
27 git shortlog HEAD >actual &&
28 test_cmp expect actual
29 '
30
31 cat >expect <<\EOF
32 Repo Guy (1):
33 initial
34
35 nick1 (1):
36 second
37
38 EOF
39
40 test_expect_success 'default .mailmap' '
41 echo "Repo Guy <author@example.com>" > .mailmap &&
42 git shortlog HEAD >actual &&
43 test_cmp expect actual
44 '
45
46 # Using a mailmap file in a subdirectory of the repo here, but
47 # could just as well have been a file outside of the repository
48 cat >expect <<\EOF
49 Internal Guy (1):
50 second
51
52 Repo Guy (1):
53 initial
54
55 EOF
56 test_expect_success 'mailmap.file set' '
57 mkdir internal_mailmap &&
58 echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
59 git config mailmap.file internal_mailmap/.mailmap &&
60 git shortlog HEAD >actual &&
61 test_cmp expect actual
62 '
63
64 cat >expect <<\EOF
65 External Guy (1):
66 initial
67
68 Internal Guy (1):
69 second
70
71 EOF
72 test_expect_success 'mailmap.file override' '
73 echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap &&
74 git config mailmap.file internal_mailmap/.mailmap &&
75 git shortlog HEAD >actual &&
76 test_cmp expect actual
77 '
78
79 cat >expect <<\EOF
80 Repo Guy (1):
81 initial
82
83 nick1 (1):
84 second
85
86 EOF
87
88 test_expect_success 'mailmap.file non-existant' '
89 rm internal_mailmap/.mailmap &&
90 rmdir internal_mailmap &&
91 git shortlog HEAD >actual &&
92 test_cmp expect actual
93 '
94
95 cat >expect <<\EOF
96 A U Thor (1):
97 initial
98
99 nick1 (1):
100 second
101
102 EOF
103 test_expect_success 'No mailmap files, but configured' '
104 rm .mailmap &&
105 git shortlog HEAD >actual &&
106 test_cmp expect actual
107 '
108
109 test_done