@@ -4,13 +4,22 @@ test_description='.mailmap configurations'
44
55. ./test-lib.sh
66
7+ fuzz_blame () {
8+ sed "
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
12+ " " $@ "
13+ }
14+
715test_expect_success setup '
816 echo one >one &&
917 git add one &&
1018 test_tick &&
1119 git commit -m initial &&
1220 echo two >>one &&
1321 git add one &&
22+ test_tick &&
1423 git commit --author "nick1 <bugs@company.xx>" -m second
1524'
1625
@@ -54,7 +63,7 @@ Repo Guy (1):
5463
5564EOF
5665test_expect_success ' mailmap.file set' '
57- mkdir internal_mailmap &&
66+ mkdir -p internal_mailmap &&
5867 echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
5968 git config mailmap.file internal_mailmap/.mailmap &&
6069 git shortlog HEAD >actual &&
@@ -92,6 +101,40 @@ test_expect_success 'mailmap.file non-existant' '
92101 test_cmp expect actual
93102'
94103
104+ cat > expect << \EOF
105+ Internal Guy (1):
106+ second
107+
108+ Repo Guy (1):
109+ initial
110+
111+ EOF
112+
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
119+ '
120+
121+ cat > expect << \EOF
122+ Internal Guy (1):
123+ second
124+
125+ Repo Guy (1):
126+ initial
127+
128+ EOF
129+
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
136+ '
137+
95138cat > expect << \EOF
96139A U Thor (1):
97140 initial
@@ -101,7 +144,7 @@ nick1 (1):
101144
102145EOF
103146test_expect_success ' No mailmap files, but configured' '
104- rm .mailmap &&
147+ rm -f .mailmap internal_mailmap/ .mailmap &&
105148 git shortlog HEAD >actual &&
106149 test_cmp expect actual
107150'
@@ -153,7 +196,7 @@ test_expect_success 'Shortlog output (complex mapping)' '
153196 test_tick &&
154197 git commit --author "CTO <cto@coompany.xx>" -m seventh &&
155198
156- mkdir internal_mailmap &&
199+ mkdir -p internal_mailmap &&
157200 echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
158201 echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
159202 echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
@@ -198,18 +241,18 @@ test_expect_success 'Log output (complex mapping)' '
198241
199242# git blame
200243cat > 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
244+ ^OBJI (A U Thor DATE 1) one
245+ OBJID (Some Dude DATE 2) two
246+ OBJID (Other Author DATE 3) three
247+ OBJID (Other Author DATE 4) four
248+ OBJID (Santa Claus DATE 5) five
249+ OBJID (Santa Claus DATE 6) six
250+ OBJID (CTO DATE 7) seven
208251EOF
209-
210252test_expect_success ' Blame output (complex mapping)' '
211253 git blame one >actual &&
212- test_cmp expect actual
254+ fuzz_blame actual >actual.fuzz &&
255+ test_cmp expect actual.fuzz
213256'
214257
215258test_done
0 commit comments