git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 2/5] contrib: contacts: add ability to parse from committish

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 21, 2013, 10:52 UTC
Message-ID
<1374403962-48361-3-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1374403962-48361-1-git-send-email-sunshine@sunshineco.com>
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 <sunshine@sunshineco.com>
---
 contrib/contacts/git-contacts | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index 3e6cce8..1686ff3 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 <file> ...
+# Usage: git contacts <file | rev-list option> ...
 
 use strict;
 use warnings;
@@ -77,8 +77,8 @@ sub get_blame {
 }
 
 sub scan_patches {
-	my ($commits, $f) = @_;
-	my ($id, $source);
+	my ($commits, $id, $f) = @_;
+	my $source;
 	while (<$f>) {
 		if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) {
 			$id = $1;
@@ -98,18 +98,44 @@ sub scan_patches {
 sub scan_patch_file {
 	my ($commits, $file) = @_;
 	open my $f, '<', $file or die "read failure: $file: $!\n";
-	scan_patches($commits, $f);
+	scan_patches($commits, undef, $f);
+	close $f;
+}
+
+sub scan_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_patches($commits, $id, $g);
+		close $g;
+	}
 	close $f;
 }
 
 if (!@ARGV) {
-	die "No input patch files\n";
+	die "No input revisions or patch files\n";
 }
 
-my %commits;
+my (@files, @rev_args);
 for (@ARGV) {
+	if (-e) {
+		push @files, $_;
+	} else {
+		push @rev_args, $_;
+	}
+}
+
+my %commits;
+for (@files) {
 	scan_patch_file(\%commits, $_);
 }
+if (@rev_args) {
+	scan_rev_args(\%commits, \@rev_args)
+}
 import_commits(\%commits);
 
 my $contacts = {};
-- 
1.8.3.3.803.gd114dc6
Previous: Eric SunshineNext: Eric Sunshine
Message 3 of 6 in “add git-contacts helper”
  1. 0/5 add git-contacts helperEric Sunshine, Jul 21, 2013
  2. 1/5 contrib: add git-contacts helperEric Sunshine, Jul 21, 2013
  3. 2/5 contrib: contacts: add ability to parse from committishEric Sunshine, Jul 21, 2013
  4. 3/5 contrib: contacts: interpret committish akin to format-patchEric Sunshine, Jul 21, 2013
  5. 4/5 contrib: contacts: add mailmap supportEric Sunshine, Jul 21, 2013
  6. 5/5 contrib: contacts: add documentationEric Sunshine, Jul 21, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.