git.shiar.nl
/
git-grep-footer.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
1e60d4e840c2dc508b55265485c4cdb9db2843bf
[git-grep-footer.git]
/
git-grep-footer
1
#!/usr/bin/perl -0 -CS
2
use 5.010;
3
use strict;
4
use warnings;
5
use Data::Dump 'pp';
6
7
my $HEADERMATCH = qr/ [a-z]+ (?: (?:-\w+)+ | \ by ) /ix;
8
9
while (readline) {
10
BLOCK:
11
for (reverse split /\n\n/) {
12
my @headers;
13
14
LINE:
15
for (split /\n/) {
16
next if not /\S/;
17
my @header = m{
18
^
19
(?<key> $HEADERMATCH)
20
: \s*
21
(?<val> \S .+)
22
$
23
}imx or next LINE;
24
25
push @headers, \@header;
26
}
27
28
next BLOCK if not @headers;
29
30
for (@headers) {
31
say join ': ', @$_;
32
}
33
34
last BLOCK;
35
}
36
}