Have you ever been working on code, gone off on a side tangent and then realized you don’t have a valid patch of the code you’ve been working on? So you run
diff -du, cvs diff, git diff or some other diff and suddenly realize you have a mix of old changes and new changes. Some you want to submit, others you don’t. What you really want to do is break those changes apart and apply only the ones you want.
Sadly, there is no tool to do that.. until now!
splitpatch will allow you to take a diff of a file and either:
- Split the patch up into change to the respective patched files
- Split the patch up into individual hunks, where each hunk can be applied separately
To use splitpatch, you’ll need ruby installed. Then simply use:
YOURPATCHFILE into a valid patch per file contained within the patch. Or
splitpatch.rb --hunks YOURPATCHFILE
To split the patch file into individual chunks which can be applied, using
Splitpatch can be downloaded from:
Patch File Format
For those who don’t think
splitpatch will do what they want, here’s at least some info about the format of a patch file.
@@ -143,6 +143,13 @@
- the first number is the starting line for this hunk in oldfile
- the second number is the number of original source lines in this hunk (this includes lines marked with “-”)
- the third number is the starting line for this hunk in newfile
- the last number is the number of lines after the hunk has been applied.
Many thanks to Peter Hutterer for this valuable trip into a patch.
Donations keep this site alive