summaryrefslogtreecommitdiff
path: root/contrib/contacts
diff options
context:
space:
mode:
authorLibravatar Eric Sunshine <sunshine@sunshineco.com>2013-08-09 17:39:54 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-08-13 09:08:58 -0700
commit9ae9ca1f95ccd3b4c1d62d856eb8b48fdff7c2d5 (patch)
tree139fda2f4b2dd14e14bef1c01b67343eaaad54d0 /contrib/contacts
parentline-range: reject -L line numbers less than 1 (diff)
downloadtgif-9ae9ca1f95ccd3b4c1d62d856eb8b48fdff7c2d5.tar.xz
contacts: validate hunk length earlier
Rather than calling get_blame() with a zero-length hunk only to have it rejected immediately, perform hunk-length validation earlier in order to avoid calling get_blame() unnecessarily. This is a preparatory step to simplify later patches which reduce the number of git-blame invocations by collecting together all lines to blame within a single file at a particular revision. By validating the blame range early, the subsequent patch can more easily avoid adding empty ranges at collection time. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/contacts')
-rwxr-xr-xcontrib/contacts/git-contacts5
1 files changed, 2 insertions, 3 deletions
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index d80f7d1b6e..4fbb2ef85a 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -60,8 +60,6 @@ sub import_commits {
sub get_blame {
my ($commits, $source, $start, $len, $from) = @_;
- $len = 1 unless defined($len);
- return if $len == 0;
open my $f, '-|',
qw(git blame --porcelain -C), '-L', "$start,+$len",
'--since', $since, "$from^", '--', $source or die;
@@ -90,7 +88,8 @@ sub scan_patches {
} elsif (/^--- /) {
die "Cannot parse hunk source: $_\n";
} elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) {
- get_blame($commits, $source, $1, $2, $id);
+ my $len = defined($2) ? $2 : 1;
+ get_blame($commits, $source, $1, $len, $id) if $len;
}
}
}