contrib: contacts: interpret committish akin to format-patch

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Jul 21, 2013 at 06:52 UTC ccf6b45aff3f89016cf1a3e39a37e73e72c3e0f6
1 file changed +18 -1
contrib/contacts/git-contacts
+18 -1
@@ -102,9 +102,26 @@ sub scan_patch_file {
102 close $f;
103 }
104
105 +sub parse_rev_args {
106 + my @args = @_;
107 + open my $f, '-|',
108 + qw(git rev-parse --revs-only --default HEAD --symbolic), @args
109 + or die;
110 + my @revs;
111 + while (<$f>) {
112 + chomp;
113 + push @revs, $_;
114 + }
115 + close $f;
116 + return @revs if scalar(@revs) != 1;
117 + return "^$revs[0]", 'HEAD' unless $revs[0] =~ /^-/;
118 + return $revs[0], 'HEAD';
119 +}
120 +
121 sub scan_rev_args {
122 my ($commits, $args) = @_;
107 - open my $f, '-|', qw(git rev-list --reverse), @$args or die;
123 + my @revs = parse_rev_args(@$args);
124 + open my $f, '-|', qw(git rev-list --reverse), @revs or die;
125 while (<$f>) {
126 chomp;
127 my $id = $_;