Skip to content

Commit 8e7c4a8

Browse files
sunshinecogitster
authored andcommitted
contrib: contacts: add ability to parse from committish
For example: % git contacts R1..R2 Committishes and patch files can be mentioned in the same invocation: % git contacts R1..R2 extra/*.patch Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d06402 commit 8e7c4a8

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

contrib/contacts/git-contacts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# List people who might be interested in a patch. Useful as the argument to
44
# git-send-email --cc-cmd option, and in other situations.
55
#
6-
# Usage: git contacts <file> ...
6+
# Usage: git contacts <file | rev-list option> ...
77

88
use strict;
99
use warnings;
@@ -77,8 +77,8 @@ sub get_blame {
7777
}
7878

7979
sub scan_patches {
80-
my ($commits, $f) = @_;
81-
my ($id, $source);
80+
my ($commits, $id, $f) = @_;
81+
my $source;
8282
while (<$f>) {
8383
if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) {
8484
$id = $1;
@@ -98,18 +98,44 @@ sub scan_patches {
9898
sub scan_patch_file {
9999
my ($commits, $file) = @_;
100100
open my $f, '<', $file or die "read failure: $file: $!\n";
101-
scan_patches($commits, $f);
101+
scan_patches($commits, undef, $f);
102+
close $f;
103+
}
104+
105+
sub scan_rev_args {
106+
my ($commits, $args) = @_;
107+
open my $f, '-|', qw(git rev-list --reverse), @$args or die;
108+
while (<$f>) {
109+
chomp;
110+
my $id = $_;
111+
$seen{$id} = 1;
112+
open my $g, '-|', qw(git show -C --oneline), $id or die;
113+
scan_patches($commits, $id, $g);
114+
close $g;
115+
}
102116
close $f;
103117
}
104118

105119
if (!@ARGV) {
106-
die "No input patch files\n";
120+
die "No input revisions or patch files\n";
107121
}
108122

109-
my %commits;
123+
my (@files, @rev_args);
110124
for (@ARGV) {
125+
if (-e) {
126+
push @files, $_;
127+
} else {
128+
push @rev_args, $_;
129+
}
130+
}
131+
132+
my %commits;
133+
for (@files) {
111134
scan_patch_file(\%commits, $_);
112135
}
136+
if (@rev_args) {
137+
scan_rev_args(\%commits, \@rev_args)
138+
}
113139
import_commits(\%commits);
114140

115141
my $contacts = {};

0 commit comments

Comments
 (0)