add alternat file option to hashfinder util
This commit is contained in:
parent
822e5a7b96
commit
168a1c04cf
|
@ -35,9 +35,9 @@
|
||||||
# hashfinder - Find origin of a particular line of code
|
# hashfinder - Find origin of a particular line of code
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
my $regex = shift;
|
my $regex = shift;
|
||||||
|
my $alt_file = shift;
|
||||||
my $delim = " ";
|
my $delim = " ";
|
||||||
|
|
||||||
$file and $regex or die "missing params. Syntax: <file> <regex>";
|
$file and $regex or die "missing params. Syntax: <file> <regex>";
|
||||||
|
@ -58,7 +58,9 @@ sub doit($$) {
|
||||||
$linematch = 1;
|
$linematch = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
open GIT, "git blame -n $file $rev|";
|
retry:
|
||||||
|
|
||||||
|
open GIT, "git blame -n $file $rev 2>&1|";
|
||||||
|
|
||||||
my $mc = 0;
|
my $mc = 0;
|
||||||
my @matches = ();
|
my @matches = ();
|
||||||
|
@ -66,6 +68,14 @@ sub doit($$) {
|
||||||
while (<GIT>) {
|
while (<GIT>) {
|
||||||
my $matched = 0;
|
my $matched = 0;
|
||||||
|
|
||||||
|
if (/fatal:/) {
|
||||||
|
if ($alt_file) {
|
||||||
|
$file = $alt_file;
|
||||||
|
$alt_file = undef;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($linematch) {
|
if ($linematch) {
|
||||||
$matched = (/^\S+\s+$pattern\s+/);
|
$matched = (/^\S+\s+$pattern\s+/);
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,7 +91,6 @@ sub doit($$) {
|
||||||
|
|
||||||
close(GIT);
|
close(GIT);
|
||||||
|
|
||||||
|
|
||||||
if ($mc > 5) {
|
if ($mc > 5) {
|
||||||
print $delim x $loops;
|
print $delim x $loops;
|
||||||
print "$mc matches; Maybe more specific?\n";
|
print "$mc matches; Maybe more specific?\n";
|
||||||
|
@ -100,10 +109,11 @@ sub doit($$) {
|
||||||
my ($hash, $lno, $author, $line);
|
my ($hash, $lno, $author, $line);
|
||||||
my $done = 0;
|
my $done = 0;
|
||||||
|
|
||||||
if (/$file/) {
|
if (/\//) {
|
||||||
($hash, $lno, $author, $line) = /(\S+)\s+\S+\s+(\S+)\s+(\([^\)]+\))\s*(.*)/;
|
($hash, $lno, $author, $line) = /(\S+)\s+\S+\s+(\S+)\s+(\([^\)]+\))\s*(.*)/;
|
||||||
$done = 1;
|
$done = 1;
|
||||||
} else {
|
} else {
|
||||||
|
die $_;
|
||||||
($hash, $lno, $author, $line) = /(\S+)\s+(\S+)\s+(\([^\)]+\))\s*(.*)/;
|
($hash, $lno, $author, $line) = /(\S+)\s+(\S+)\s+(\([^\)]+\))\s*(.*)/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue