reset (debug) junk counter between blocks
[git-grep-footer.git] / git-grep-footer
index 0c26549197cfddfa4eeb8e511edd4aab1134dcde..c39222fd9d6a3280cd817d88d72e1d086bfc8a64 100755 (executable)
@@ -28,7 +28,7 @@ my $HEADERMATCH = qr/ [a-z]+ (?: (?:-\w+)+ | \ by ) /ix;
 my (%headercount, @headercache);
 
 while (readline) {
-       s/(.+)\n//m;
+       s/^([0-9a-f]{4,40})\n//m and
        my $hash = $1;
 
        # strip commit seperator
@@ -40,12 +40,12 @@ while (readline) {
        # if invalid, assume it's latin1
               $_ = decode(cp1252 => $_) if $@;
 
-       my $prefix = 0;
        my %attr;
 
        BLOCK:
        for (reverse split /\n\n/) {
                my @headers;
+               my $prefix = 0;
 
                LINE:
                for (split /\n/) {
@@ -118,11 +118,13 @@ while (readline) {
                next BLOCK if not @headers;
 
                if ($opt{debug} and $prefix) {
-                       say "infix junk in commit $hash";
+                       say sprintf ': invalid lines in %s (%s)', $hash // 'block', $prefix;
                }
 
                for (@headers) {
                        my $line = $_->[2] // join(': ', @$_);
+                       $line =~ s/^/$hash / if defined $hash;
+
                        if (defined $opt{min} or $opt{max}) {
                                my $counter = \$headercount{ $_->[0] }->{ $_->[1] // '' };
                                my $excess = $$counter++ - ($opt{min} // 0);