Skip to content

Commit 7c6d6ff

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ccf6b45 commit 7c6d6ff

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contrib/contacts/git-contacts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ sub scan_rev_args {
133133
close $f;
134134
}
135135

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+
136153
if (!@ARGV) {
137154
die "No input revisions or patch files\n";
138155
}
@@ -161,6 +178,7 @@ for my $commit (values %commits) {
161178
$contacts->{$contact}++;
162179
}
163180
}
181+
$contacts = mailmap_contacts($contacts);
164182

165183
my $ncommits = scalar(keys %commits);
166184
for my $contact (keys %$contacts) {

0 commit comments

Comments
 (0)