git.shiar.nl
/
git-grep-footer.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
784eaf2
)
convert non-utf8; avoid buffering; debug unmatched values
author
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 3 Feb 2011 18:56:28 +0000
(19:56 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 3 Feb 2011 18:56:28 +0000
(19:56 +0100)
git-grep-footer
patch
|
blob
|
history
diff --git
a/git-grep-footer
b/git-grep-footer
index 1e60d4e840c2dc508b55265485c4cdb9db2843bf..6952508cdb94a4ca84c97857fe60fbbc8c481b5c 100755
(executable)
--- a/
git-grep-footer
+++ b/
git-grep-footer
@@
-1,12
+1,35
@@
-#!/usr/bin/perl -0 -C
S
+#!/usr/bin/perl -0 -C
O
use 5.010;
use strict;
use warnings;
use 5.010;
use strict;
use warnings;
+use Encode 'decode';
use Data::Dump 'pp';
use Data::Dump 'pp';
+use Getopt::Long;
+
+GetOptions(\my %opt,
+ 'debug!',
+) or die;
+
+local $| = 1;
my $HEADERMATCH = qr/ [a-z]+ (?: (?:-\w+)+ | \ by ) /ix;
while (readline) {
my $HEADERMATCH = qr/ [a-z]+ (?: (?:-\w+)+ | \ by ) /ix;
while (readline) {
+ s/(.+)\n//m;
+ my $hash = $1;
+
+ # strip commit seperator
+ chomp;
+ # skip expensive checks without potential identifier
+ m/:/ or next;
+ # try to parse as UTF-8
+ eval { $_ = decode(utf8 => $_, Encode::FB_CROAK()) };
+ # if invalid, assume it's latin1
+ $_ = decode(cp1252 => $_) if $@;
+
+ my $prefix = 0;
+ my %attr;
+
BLOCK:
for (reverse split /\n\n/) {
my @headers;
BLOCK:
for (reverse split /\n\n/) {
my @headers;
@@
-20,13
+43,20
@@
while (readline) {
: \s*
(?<val> \S .+)
$
: \s*
(?<val> \S .+)
$
- }imx or next LINE;
+ }imx or do {
+ $prefix++;
+ next LINE;
+ };
push @headers, \@header;
}
next BLOCK if not @headers;
push @headers, \@header;
}
next BLOCK if not @headers;
+ if ($opt{debug} and $prefix) {
+ say "infix junk in commit $hash";
+ }
+
for (@headers) {
say join ': ', @$_;
}
for (@headers) {
say join ': ', @$_;
}