Diffutils - patching software with .diff files

July 15th, 2006 | Filed under Open source, Unix

Now that I’m running an open source project with a mailing list of developers much more skilled than I am, I’ve got folks emailing in code patches in the form of .diff files. Having never dealt with .diff’s before (I know, I know, Windows baby here) I dove into the GNU diffutils manual. This kind of stuff still scares the crap out of me, but:

$ patch todo.sh todocolour.diff

Applied the submitted file differences to the source code, and I was able to run my unit tests straightaway without hand-adding edited code line by line.

Patch added the changed lines to the original file (todo.sh) and created a todo.sh.orig file as well. If it fails on merging any file differences, it creates a todo.sh.rej file.

Simple, useful and handy.

Diffutils [GNU Project - Free Software Foundation (FSF)]