contrib / stats / mailmap.plon commit contrib/diffall: comment actual reason for 'cdup' (a22a947)
   1#!/usr/bin/perl -w
   2my %mailmap = ();
   3open I, "<", ".mailmap";
   4while (<I>) {
   5        chomp;
   6        next if /^#/;
   7        if (my ($author, $mail) = /^(.*?)\s+<(.+)>$/) {
   8                $mailmap{$mail} = $author;
   9        }
  10}
  11close I;
  12
  13my %mail2author = ();
  14open I, "git log --pretty='format:%ae   %an' |";
  15while (<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}
  23close I;
  24
  25while (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