I don’t really do much Unix development, but I’ve recently been learning more due to the care and feeding of my blog. Lately I’ve been figuring out some things about the
patch utility, especially creating and applying patches. I found a decent tutorial on
diff which are the two tools needed to apply and create (respectively) patch files. The tutorial goes into much more depth than I would ever attempt. It’s also well written, so I’ll just point people there instead of re-inventing the wheel. But I think a “diff & patch” nutshell usage would be appropriate, so here it is.
Creating a patch (individual files)
diff -u old-file new-file >patch-file
Creating a patch (whole directory/tree)
diff -urN old-directory new-directory >patch-file
Applying a patch (individual file or whole directory/tree)
While reading the article, I discovered that I had made some mistakes when I created at least one of my patchfiles, so I went through all my patch-related posts and re-created everything. I’m very glad I did! I found a whole bunch of small corrections I had made to BorderlineChaos which I’d forgotten to document and/or release in my post on Borderline Chaos’s date format. Likewise, I made many minor changes which I didn’t document in my journalized-blue post. Finally, the patch for Felix Wong’s tags plugin was definitely broken. I’ve corrected it and updated the original article.