Skip to content

Commit af6861b

Browse files
committed
Add contrib/stats/mailmap.pl script
This script reads the existing commit log and .mailmap file, and outputs author e-mail addresses that would map to more than one names (most likely due to difference in the way they are spelled, but some are due to ancient botched commits). Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9d6f220 commit af6861b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

contrib/stats/mailmap.pl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/perl -w
2+
my %mailmap = ();
3+
open I, "<", ".mailmap";
4+
while (<I>) {
5+
chomp;
6+
next if /^#/;
7+
if (my ($author, $mail) = /^(.*?)\s+<(.+)>$/) {
8+
$mailmap{$mail} = $author;
9+
}
10+
}
11+
close I;
12+
13+
my %mail2author = ();
14+
open I, "git log --pretty='format:%ae %an' |";
15+
while (<I>) {
16+
chomp;
17+
my ($mail, $author) = split(/\t/, $_);
18+
next if exists $mailmap{$mail};
19+
$mail2author{$mail} ||= {};
20+
$mail2author{$mail}{$author} ||= 0;
21+
$mail2author{$mail}{$author}++;
22+
}
23+
close I;
24+
25+
while (my ($mail, $authorcount) = each %mail2author) {
26+
# %$authorcount is ($author => $count);
27+
# sort and show the names from the most frequent ones.
28+
my @names = (map { $_->[0] }
29+
sort { $b->[1] <=> $a->[1] }
30+
map { [$_, $authorcount->{$_}] }
31+
keys %$authorcount);
32+
if (1 < @names) {
33+
for (@names) {
34+
print "$_ <$mail>\n";
35+
}
36+
}
37+
}
38+

0 commit comments

Comments
 (0)