Jeff King <p...@peff.net> writes:

> Running:
>
>   git diff origin origin/jk/test-chain-lint |
>   perl diff-blame.pl jk/test-chain-lint |
>   grep EOF
>
> was fun. At least I am not the only one. :)

The parameter to diff-blame.pl should be origin, instead of
jk/test-chain-lint, I presume?  You are grabbing the preimage line
numbers and asking blame to find out who wrote them.

> Nor the worst in the "severe" category.

I do not quite get what this means---the script does not seem to
judge what is severe and what is not, so I presume that this is to
be judged by whoever is reading the output from the above pipeline
after replacing "grep EOF" with "less" or something?

> # diff-blame.pl
> use warnings FATAL => 'all';
> use strict;
>
> my $head = shift
>   or die "usage: git diff <start> <end> | $0 <start> [blame-opts]";
>
> my $file;
> my @lines;
> my $line_nr;
>
> while (<STDIN>) {
>   if (m{^--- .*?/(.*)}) {

This may match a removal of a line that begins with "^-- something/" ;-)

>     flush();
>     $file = $1;
>     @lines = ();
>   }
>   elsif (m{^@@ -(\d+)}) {
>     $line_nr = $1;
>   }
>   elsif (m{^ }) {
>     $line_nr++;
>   }
>   elsif (m{^-}) {
>     push @lines, $line_nr++;
>   }
> }
> flush();
> exit 0;
>
> sub flush {
>   return unless defined $file && @lines > 0;
>
>   # XXX coalesce blocks of adjacent lines into ranges?
>   system(qw(git --no-pager blame), @ARGV,

You may want to pass an option to always show the filename here.

>          (map { "-L$_,$_" } @lines), $head, $file);
> }
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to