kinda goofy, but it helps when breaking up large patches (esp. useful when trying to update an old linux kernel patch to a newer kernel and things just don't line up...) :
#!/usr/bin/perl if ( ! @ARGV ) { print "Usage : $0 patch1 patch2 ...\n"; exit 1; } # path to put output in $outputroot = $ENV{"HOME"}; $outputdir = "$outputroot/patch-divide"; if ( ! -d $outputdir ) { mkdir("$outputdir",0777) } foreach $patch ( @ARGV ) { $outputbase = "$outputdir/$patch"; open(INPUT,"$patch") || die "Can't open $patch : $! \n"; $count = 0; while(<INPUT>) { if(!<OUTPUT>) { open(OUTPUT,">>$outputbase.$count") || die "No output"; } if (!/^diff/) { print OUTPUT; } else { ( $count == 0 ) && print OUTPUT "$patch"; $count++; close(OUTPUT) || warn "Couldn't close : $!\n"; } } } close(INPUT);