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

[PATCH v3 3/5] contrib: contacts: interpret committish akin to format-patch

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 21, 2013, 10:52 UTC
Message-ID
<1374403962-48361-4-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1374403962-48361-1-git-send-email-sunshine@sunshineco.com>

As a convenience, accept the same style <since> committish as accepted by git-format-patch. For example:

  % git contacts origin

will consider commits in the current branch built atop 'origin', just as "git format-patch origin" will format commits built atop 'origin'.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 contrib/contacts/git-contacts | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index 1686ff3..4553add 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -102,9 +102,26 @@ sub scan_patch_file {
 	close $f;
 }
 
+sub parse_rev_args {
+	my @args = @_;
+	open my $f, '-|',
+		qw(git rev-parse --revs-only --default HEAD --symbolic), @args
+		or die;
+	my @revs;
+	while (<$f>) {
+		chomp;
+		push @revs, $_;
+	}
+	close $f;
+	return @revs if scalar(@revs) != 1;
+	return "^$revs[0]", 'HEAD' unless $revs[0] =~ /^-/;
+	return $revs[0], 'HEAD';
+}
+
 sub scan_rev_args {
 	my ($commits, $args) = @_;
-	open my $f, '-|', qw(git rev-list --reverse), @$args or die;
+	my @revs = parse_rev_args(@$args);
+	open my $f, '-|', qw(git rev-list --reverse), @revs or die;
 	while (<$f>) {
 		chomp;
 		my $id = $_;
-- 
1.8.3.3.803.gd114dc6
Previous: Eric SunshineNext: Eric Sunshine
Message 4 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.