Skip to content

Instantly share code, notes, and snippets.

@sidcha
Created April 21, 2019 09:38
Show Gist options
  • Save sidcha/c1d2fce0bd5ef31115c59fc953f00f2f to your computer and use it in GitHub Desktop.
Save sidcha/c1d2fce0bd5ef31115c59fc953f00f2f to your computer and use it in GitHub Desktop.
Splits or dissects large patch file into smaller per-file-change patches. Comes in handy when patches don't apply anymore.
#!/bin/perl
while (<>) {
if(/^diff --git a\/(\S+)/) {
close $f if $f;
$s=$1;
$s =~ s:(/|\.):_:g;
$n=sprintf("%03d_%s.patch", ++$i, $s);
open $f, ">", $n;
print $f $_;
next;
}
print $f $_ if $f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment