Code

Update jk/maint-strbuf-missing-init to builtin/ rename
[git.git] / t / t4203-mailmap.sh
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         git commit --author "nick1 <bugs@company.xx>" -m second
15 '
17 cat >expect <<\EOF
18 A U Thor (1):
19       initial
21 nick1 (1):
22       second
24 EOF
26 test_expect_success 'No mailmap' '
27         git shortlog HEAD >actual &&
28         test_cmp expect actual
29 '
31 cat >expect <<\EOF
32 Repo Guy (1):
33       initial
35 nick1 (1):
36       second
38 EOF
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 '
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
52 Repo Guy (1):
53       initial
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 '
64 cat >expect <<\EOF
65 External Guy (1):
66       initial
68 Internal Guy (1):
69       second
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 '
79 cat >expect <<\EOF
80 Repo Guy (1):
81       initial
83 nick1 (1):
84       second
86 EOF
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 '
95 cat >expect <<\EOF
96 A U Thor (1):
97       initial
99 nick1 (1):
100       second
102 EOF
103 test_expect_success 'No mailmap files, but configured' '
104         rm .mailmap &&
105         git shortlog HEAD >actual &&
106         test_cmp expect actual
109 # Extended mailmap configurations should give us the following output for shortlog
110 cat >expect <<\EOF
111 A U Thor <author@example.com> (1):
112       initial
114 CTO <cto@company.xx> (1):
115       seventh
117 Other Author <other@author.xx> (2):
118       third
119       fourth
121 Santa Claus <santa.claus@northpole.xx> (2):
122       fifth
123       sixth
125 Some Dude <some@dude.xx> (1):
126       second
128 EOF
130 test_expect_success 'Shortlog output (complex mapping)' '
131         echo three >>one &&
132         git add one &&
133         test_tick &&
134         git commit --author "nick2 <bugs@company.xx>" -m third &&
136         echo four >>one &&
137         git add one &&
138         test_tick &&
139         git commit --author "nick2 <nick2@company.xx>" -m fourth &&
141         echo five >>one &&
142         git add one &&
143         test_tick &&
144         git commit --author "santa <me@company.xx>" -m fifth &&
146         echo six >>one &&
147         git add one &&
148         test_tick &&
149         git commit --author "claus <me@company.xx>" -m sixth &&
151         echo seven >>one &&
152         git add one &&
153         test_tick &&
154         git commit --author "CTO <cto@coompany.xx>" -m seventh &&
156         mkdir internal_mailmap &&
157         echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
158         echo "<cto@company.xx>                       <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
159         echo "Some Dude <some@dude.xx>         nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
160         echo "Other Author <other@author.xx>   nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
161         echo "Other Author <other@author.xx>         <nick2@company.xx>" >> internal_mailmap/.mailmap &&
162         echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
163         echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
165         git shortlog -e HEAD >actual &&
166         test_cmp expect actual
170 # git log with --pretty format which uses the name and email mailmap placemarkers
171 cat >expect <<\EOF
172 Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
173 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
175 Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
176 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
178 Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
179 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
181 Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
182 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
184 Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
185 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
187 Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
188 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
190 Author A U Thor <author@example.com> maps to A U Thor <author@example.com>
191 Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
192 EOF
194 test_expect_success 'Log output (complex mapping)' '
195         git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
196         test_cmp expect actual
199 # git blame
200 cat >expect <<\EOF
201 ^3a2fdcb (A U Thor     2005-04-07 15:13:13 -0700 1) one
202 7de6f99b (Some Dude    2005-04-07 15:13:13 -0700 2) two
203 5815879d (Other Author 2005-04-07 15:14:13 -0700 3) three
204 ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four
205 5ab6d4fa (Santa Claus  2005-04-07 15:16:13 -0700 5) five
206 38a42d8b (Santa Claus  2005-04-07 15:17:13 -0700 6) six
207 8ddc0386 (CTO          2005-04-07 15:18:13 -0700 7) seven
208 EOF
210 test_expect_success 'Blame output (complex mapping)' '
211         git blame one >actual &&
212         test_cmp expect actual
215 test_done