|
用了一下,还好,就是把一个大的patch集合分解开来,有的时候挺方便的。
- #!/usr/bin/perl
- #
- # simple script to split a diff in one file
- # for each touched file
- while(<>) {
- if (/^---/) {
- @a = split(/[ \t]+/);
- $fn = $a[1];
- $fn =~ tr/\//_/;
- if (-e $fn) {
- $i = 1;
- while(-e "$fn.$i") {
- $i++;
- }
- $fn .= ".$i";
- }
- print $fn;
- print "\n";
- close OUT;
- open OUT, "> $fn" or die "Couldn't open $fn";
- print OUT $buffer;
- $buffer = "";
- }
- if (/^[+\- @]/) {
- print OUT $_;
- } else {
- $buffer .= $_;
- }
- }
复制代码 |
|