1*cdf0e10cSrcweir#!/usr/bin/perl -w 2*cdf0e10cSrcweir 3*cdf0e10cSrcweirmy @output_buffer = (); 4*cdf0e10cSrcweirmy $fname; 5*cdf0e10cSrcweirmy $detectedSomeGuff = 0; 6*cdf0e10cSrcweirsub pure_guff($) 7*cdf0e10cSrcweir{ 8*cdf0e10cSrcweir my $array = shift; 9*cdf0e10cSrcweir my @lines = @{$array}; 10*cdf0e10cSrcweir my $contains_sense = ''; 11*cdf0e10cSrcweir my $contains_guff = ''; 12*cdf0e10cSrcweir while (scalar @lines) 13*cdf0e10cSrcweir { 14*cdf0e10cSrcweir my $line = pop @lines; 15*cdf0e10cSrcweir if ($line =~ m/Test run started :/ || 16*cdf0e10cSrcweir $line =~ m/ITEM Assertion OK/ || 17*cdf0e10cSrcweir $line =~ m/Test run finished :/) { 18*cdf0e10cSrcweir $contains_guff = '1'; 19*cdf0e10cSrcweir } elsif ($line =~ m/^[\+\-][^\-\+]/) { 20*cdf0e10cSrcweir $contains_sense = '1'; 21*cdf0e10cSrcweir } 22*cdf0e10cSrcweir } 23*cdf0e10cSrcweir if ($contains_guff && $contains_sense) { 24*cdf0e10cSrcweir print STDERR "Patch fragment with mixed good/bad changes in '$ARGV' near $line_index\n"; 25*cdf0e10cSrcweir $contains_guff = ''; 26*cdf0e10cSrcweir } 27*cdf0e10cSrcweir elsif ( $contains_guff ) { 28*cdf0e10cSrcweir $detectedSomeGuff++; 29*cdf0e10cSrcweir } 30*cdf0e10cSrcweir# print "contains guff: $contains_guff\n"; 31*cdf0e10cSrcweir return $contains_guff; 32*cdf0e10cSrcweir} 33*cdf0e10cSrcweir 34*cdf0e10cSrcweirsub output_lines($) 35*cdf0e10cSrcweir{ 36*cdf0e10cSrcweir my $array = shift; 37*cdf0e10cSrcweir my @lines = @{$array}; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir if (pure_guff (\@lines)) { 40*cdf0e10cSrcweir return; 41*cdf0e10cSrcweir } 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir while (scalar @lines) 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir my $line = pop @lines; 46*cdf0e10cSrcweir push @output_buffer, $line; 47*cdf0e10cSrcweir } 48*cdf0e10cSrcweir} 49*cdf0e10cSrcweir 50*cdf0e10cSrcweirmy $header; 51*cdf0e10cSrcweirmy @lines; 52*cdf0e10cSrcweirmy $frag_count = 0; 53*cdf0e10cSrcweir$line_index = 0; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweirwhile (<>) { 56*cdf0e10cSrcweir if (/^\@\@/ || /^[^ \-\+]/) { 57*cdf0e10cSrcweir output_lines (\@lines); 58*cdf0e10cSrcweir @lines = (); 59*cdf0e10cSrcweir $frag_count++; 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir unshift @lines, $_; 62*cdf0e10cSrcweir $line_index++; 63*cdf0e10cSrcweir close ARGV if eof; 64*cdf0e10cSrcweir} 65*cdf0e10cSrcweiroutput_lines(\@lines); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir# $detectedSomeGuff contains the skipped hunks that contain acceptable diff 68*cdf0e10cSrcweir# e.g. a timestamp or an OK assertion that contains different content 69*cdf0e10cSrcweir# like perhaps a path 70*cdf0e10cSrcweir#print "frag_count = $frag_count fragstocount = $fragstocount detectedSomeGuff = $detectedSomeGuff \n"; 71*cdf0e10cSrcweirif ($frag_count > $detectedSomeGuff) { 72*cdf0e10cSrcweir print @output_buffer; 73*cdf0e10cSrcweir} 74