Re: Git help for kernel archeology, suppress diffs caused by CVS keyword expansion
From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:23
Hi, On Sun, 22 Jul 2007, Jon Smirl wrote:
On 7/22/07, Johannes Schindelin [off-list ref] wrote:quoted
quoted
This doesn't run on the two full kernel samples I sent you.You mean my script? Or your C program?Your script, I sent two big samples directly to you as attachments three hours ago.
Okay, I did not really test thoroughly, it seems. Sorry. Next try.
Ciao,
Dscho
-- snipsnap --
#!/usr/bin/perl
sub init_hunk {
$_ = $_[0];
$current_hunk = "";
$current_hunk_header = $_;
($start_minus, $dummy, $start_plus, $dummy) =
/^\@\@ -(\d+)(,\d+|) \+(\d+)(,\d+|) \@\@/;
$plus = $minus = $space = 0;
$skip_logs = 0;
$key = 0;
}
sub flush_hunk {
if ($plus > 0 || $minus > 0) {
if ($current_file ne "") {
print $current_file;
$current_file = "";
}
$minus += $space;
$plus += $space;
print "\@\@ -$start_minus,$minus "
. "+$start_plus,$plus \@\@\n";
print $current_hunk;
}
}
sub check_file {
$_ = $_[0];
$current_file = $_;
while (<>) {
if (/^\@\@/) {
last;
}
$current_file .= $_;
}
init_hunk $_;
# check hunks
while (<>) {
if ($skip_logs && /^\+ *\*/) {
# do nothing
} elsif ($key && /^\+.*\$$key.*\$/) {
# do nothing
} elsif (/^\@\@.*/) {
flush_hunk;
init_hunk $_;
} elsif (/^diff/) {
flush_hunk;
return;
} elsif (/^-.*\$(Id|Revision|Author|Date).*\$/) {
$key = $1;
s/^-/ /;
$current_hunk .= $_;
$space++;
$skip_logs = 0;
$key = 0;
} elsif (/^ .*\$Log.*\$/) {
$current_hunk .= $_;
$space++;
$skip_logs = 1;
$key = 0;
} elsif (/^ /) {
$current_hunk .= $_;
$space++;
$skip_logs = 0;
$key = 0;
} elsif (/^\+/) {
$current_hunk .= $_;
$plus++;
$key = 0;
} elsif (/^-/) {
$current_hunk .= $_;
$minus++;
$skip_logs = 0;
$key = 0;
} elsif (/^\\/) {
print $_;
} else {
die "Unexpected line: $_";
}
}
}
while (<>) {
if (/^diff/) {
do {
check_file $_;
} while(/^diff/);
} else {
printf $_;
}
}