From: Eric Sunshine Date: Sun, 30 Jun 2013 11:08:31 GMT Subject: [PATCH/RFC 3/4] contrib: contacts: add ability to parse from committish Message-ID: <1372590512-21341-4-git-send-email-sunshine@sunshineco.com> In-Reply-To: <1372590512-21341-1-git-send-email-sunshine@sunshineco.com> Committishes can be mentioned along with patch files in the same invocation. For example: % git contacts master..feature extra/*.patch Signed-off-by: Eric Sunshine --- contrib/contacts/git-contacts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts index ab11670..abb90a1 100755 --- a/contrib/contacts/git-contacts +++ b/contrib/contacts/git-contacts @@ -3,7 +3,7 @@ # List people who might be interested in a patch. Useful as the argument to # git-send-email --cc-cmd option, and in other situations. # -# Usage: git contacts ... +# Usage: git contacts ... use strict; use warnings; @@ -104,8 +104,32 @@ sub commits_from_patch { close $f; } +sub commits_from_rev_args { + my ($commits, $args) = @_; + open my $f, '-|', qw(git rev-list --reverse), @$args or die; + while (<$f>) { + chomp; + my $id = $_; + $seen{$id} = 1; + open my $g, '-|', qw(git show -C --oneline), $id or die; + scan_hunks($commits, $id, $g); + close $g; + } + close $f; +} + +my (@files, @rev_args); +for (@ARGV) { + if (-e) { + push @files, $_; + } else { + push @rev_args, $_; + } +} + my %commits; -commits_from_patch(\%commits, $_) for (@ARGV); +commits_from_patch(\%commits, $_) for (@files); +commits_from_rev_args(\%commits, \@rev_args) if @rev_args; import_commits(\%commits); my %count_per_person; -- 1.8.3.2