summaryrefslogtreecommitdiff
path: root/contrib/contacts/git-contacts
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2013-08-09 21:39:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-08-13 16:09:03 (GMT)
commit4c70cfbfbc2da8d0e4f94b73e37b4020704a498b (patch)
tree9b1bfbedc1f2bcc1bba957de41c08d51ae94b33c /contrib/contacts/git-contacts
parentdb8cae7e6035dd56970c88ac9e34bce1baa0f665 (diff)
downloadgit-4c70cfbfbc2da8d0e4f94b73e37b4020704a498b.zip
git-4c70cfbfbc2da8d0e4f94b73e37b4020704a498b.tar.gz
git-4c70cfbfbc2da8d0e4f94b73e37b4020704a498b.tar.bz2
contacts: reduce git-blame invocations
git-contacts invokes git-blame once for each patch hunk it encounters. No attempt is made to consolidate invocations for multiple hunks referencing the same file at the same revision. This can become expensive quickly. Reduce the number of git-blame invocations by taking advantage of the ability to specify multiple -L ranges for a single invocation. Without this patch, on a randomly chosen range of commits: % time git-contacts 25fba78d36be6297^..23c339c0f262aad2 >/dev/null real 0m6.142s user 0m5.429s sys 0m0.356s With this patch: % time git-contacts 25fba78d36be6297^..23c339c0f262aad2 >/dev/null real 0m2.285s user 0m2.093s sys 0m0.165s Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/contacts/git-contacts')
-rwxr-xr-xcontrib/contacts/git-contacts11
1 files changed, 5 insertions, 6 deletions
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index b4d3526..fb6429b 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -59,9 +59,11 @@ sub import_commits {
}
sub get_blame {
- my ($commits, $source, $start, $len, $from) = @_;
+ my ($commits, $source, $from, $ranges) = @_;
+ return unless @$ranges;
open my $f, '-|',
- qw(git blame --porcelain -C), '-L', "$start,+$len",
+ qw(git blame --porcelain -C),
+ map({"-L$_->[0],+$_->[1]"} @$ranges),
'--since', $since, "$from^", '--', $source or die;
while (<$f>) {
if (/^([0-9a-f]{40}) \d+ \d+ \d+$/) {
@@ -78,10 +80,7 @@ sub blame_sources {
my ($sources, $commits) = @_;
for my $s (keys %$sources) {
for my $id (keys %{$sources->{$s}}) {
- for my $range (@{$sources->{$s}{$id}}) {
- get_blame($commits, $s,
- $range->[0], $range->[1], $id);
- }
+ get_blame($commits, $s, $id, $sources->{$s}{$id});
}
}
}