contrib: contacts: add mailmap support

The purpose of git-contacts is to determine a list of people who might have some interest in a patch or set of changes. It can be used as git-send-email's --cc-cmd argument or the computed list might be used to ask for comments on a proposed change. As such, it is important to report up-to-date email addresses in the computed list rather than potentially outdated ones recorded with commits. Apply git's mailmap functionality to the retrieved contacts in order to achieve this goal. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Jul 21, 2013 at 06:52 UTC 7c6d6ff8f122b10d6214c4f53e3179996dee2f9a
1 file changed +18
contrib/contacts/git-contacts
+18
@@ -133,6 +133,23 @@ sub scan_rev_args {
133 close $f;
134 }
135
136 +sub mailmap_contacts {
137 + my ($contacts) = @_;
138 + my %mapped;
139 + my $pid = open2 my $reader, my $writer, qw(git check-mailmap --stdin);
140 + for my $contact (keys(%$contacts)) {
141 + print $writer "$contact\n";
142 + my $canonical = <$reader>;
143 + chomp $canonical;
144 + $mapped{$canonical} += $contacts->{$contact};
145 + }
146 + close $reader;
147 + close $writer;
148 + waitpid($pid, 0);
149 + die "git-check-mailmap error: $?\n" if $?;
150 + return \%mapped;
151 +}
152 +
153 if (!@ARGV) {
154 die "No input revisions or patch files\n";
155 }
@@ -161,6 +178,7 @@ for my $commit (values %commits) {
178 $contacts->{$contact}++;
179 }
180 }
181 +$contacts = mailmap_contacts($contacts);
182
183 my $ncommits = scalar(keys %commits);
184 for my $contact (keys %$contacts) {