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:
c4f5470
)
sample options (original line(s), unique threshold)
author
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 3 Feb 2011 23:09:39 +0000
(
00:09
+0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Fri, 4 Feb 2011 00:47:28 +0000
(
01:47
+0100)
git-grep-footer
patch
|
blob
|
history
diff --git
a/git-grep-footer
b/git-grep-footer
index bc71345250a9190b0e9297b4b1e0572dfc6df5a5..906ae929f56f1cb439af2dcb0cc9c7dbbace0e4e 100755
(executable)
--- a/
git-grep-footer
+++ b/
git-grep-footer
@@
-10,8
+10,9
@@
use Getopt::Long;
GetOptions(\my %opt,
'debug!',
'simplify|s:s',
GetOptions(\my %opt,
'debug!',
'simplify|s:s',
- 'unique|u!',
'ignore-case|i!',
'ignore-case|i!',
+ 'min|min-count|unique|u:i',
+ 'max|max-count|show|n:i',
) or die;
local $| = 1;
) or die;
local $| = 1;
@@
-53,6
+54,8
@@
while (readline) {
next LINE;
};
next LINE;
};
+ push @header, $_ if defined $opt{max};
+
given ($opt{simplify} // 'no') {
when ('strict') {
$header[1] =~ s{
given ($opt{simplify} // 'no') {
when ('strict') {
$header[1] =~ s{
@@
-64,7
+67,7
@@
while (readline) {
}
when (['text', '']) {
when ($header[0] =~ /[ _-] (?: by | to ) $/imsx) {
}
when (['text', '']) {
when ($header[0] =~ /[ _-] (?: by | to ) $/imsx) {
-
pop @header
;
+
$header[1] = undef
;
}
for ($header[1]) {
s{\b (https?)://\S+ }{[$1]}gmsx; # url
}
for ($header[1]) {
s{\b (https?)://\S+ }{[$1]}gmsx; # url
@@
-74,7
+77,7
@@
while (readline) {
}
}
when (['all', 'any']) {
}
}
when (['all', 'any']) {
-
pop @header
;
+
$header[1] = undef
;
}
when ('no') {
}
}
when ('no') {
}
@@
-84,9
+87,11
@@
while (readline) {
}
if ($opt{'ignore-case'}) {
}
if ($opt{'ignore-case'}) {
- $_ = lc for
@header
;
+ $_ = lc for
$header[0], $header[1] // ()
;
}
}
+ pop @header if not defined $header[-1];
+
push @headers, \@header;
}
push @headers, \@header;
}
@@
-97,11
+102,13
@@
while (readline) {
}
for (@headers) {
}
for (@headers) {
- if (
$opt{unique
}) {
+ if (
defined $opt{min} or $opt{max
}) {
state $seen;
state $seen;
- next if $seen->{ $_->[0] }->{ $_->[1] // '' }++;
+ my $count = $seen->{ $_->[0] }->{ $_->[1] // '' }++;
+ next if $count >= ($opt{min} // 0) + ($opt{max} || 1);
+ next if $count < ($opt{min} // 0);
}
}
- say
join ': ', @$_
;
+ say
$_->[2] // join(': ', @$_)
;
}
last BLOCK;
}
last BLOCK;