ClearChain

Splitting A Patch

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.rb

Peter Hutterer, whilst working at the Wearable Computer Lab at University of South Australia faced this very problem. So he wrote the program, splitpatch.

splitpatch will allow you to take a diff of a file and either:

Usage

To use splitpatch, you’ll need ruby installed. Then simply use:

splitpatch.rb YOURPATCHFILE

To split 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 patch

Download

Splitpatch can be downloaded from:

http://github.com/benjsc/splitpatch/

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 @@

Many thanks to Peter Hutterer for this valuable trip into a patch.

Exit mobile version