Skip to content

Commit ccf6b45

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8e7c4a8 commit ccf6b45

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

contrib/contacts/git-contacts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,26 @@ sub scan_patch_file {
102102
close $f;
103103
}
104104

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+
105121
sub scan_rev_args {
106122
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;
108125
while (<$f>) {
109126
chomp;
110127
my $id = $_;

0 commit comments

Comments
 (0)