Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tool to find a specific diff hunk
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
|
||
#usage: cat mayday.diff | utils/hunkfinder.pl data/init/interface.txt 24 | ||
|
||
my $filename = $ARGV[0] or die "need filename of diffed file"; | ||
my $hunkno = $ARGV[1] or die "need hunknumber as second arg"; | ||
|
||
my $infile = 0; | ||
my $hunk = 0; | ||
my $switched = 0; | ||
|
||
while(<STDIN>) { | ||
$switched = 0; | ||
$infile = 1, $switched = 1 if(!$infile && /^diff (.*?)\Q$filename\E/); | ||
if($infile) { | ||
if(/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/) { | ||
$hunk++; | ||
} | ||
if($hunk == $hunkno) { | ||
print; | ||
} | ||
$infile = 0 if(!$switched && /^diff /); | ||
} | ||
} |