send-email: recognize absolute path on Windows
[gitweb.git] / contrib / contacts / git-contacts
index b4d3526a4666bb737db56f64771fcddf3e7afca7..428cc1a9a1367e36c2739cb226a0ffdd2704ce82 100755 (executable)
@@ -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});
                }
        }
 }
@@ -182,6 +181,10 @@ if (@rev_args) {
        scan_rev_args(\%sources, \@rev_args)
 }
 
+my $toplevel = `git rev-parse --show-toplevel`;
+chomp $toplevel;
+chdir($toplevel) or die "chdir failure: $toplevel: $!\n";
+
 my %commits;
 blame_sources(\%sources, \%commits);
 import_commits(\%commits);