More than you really wanted to know about Patch

signa11 | 139 points

If you ever find yourself needing to maintain a set of patches to apply to two or more similar codebases (e.g. various linux kernels of various distros), I found stacked git to be very helpful for that purpose. http://www.procode.org/stgit/ (or maybe just apt-get install stgit).

smcameron | 5 years ago

Of course, this idea goes back further than "back in the 1980s" with Larry Wall.

In the mainframe world of the decade before that, people had ZAP, which later was to become SPZAP, OBJZAP, and AMASPZAP (not IAMASPZAP as the Hacker's Dictionary erroneously has it). ZAP's "NAME", "VER", and "REP" records work similarly to the process described by M. Landley: name the file, verify that the original contents at a particular place are thus, replace them with some new contents if so.

ZAP could also twiddle metadata, record patches applied, and dump contents. It has several imitators.

* https://ibm.com/support/knowledgecenter/en/SSB27U_6.4.0/com....

* https://ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com....

* https://support.sas.com/documentation/onlinedoc/sasc/doc/tec...

* https://m204wiki.rocketsoftware.com/index.php/RockZap

JdeBP | 5 years ago

I was very surprised to learn that diff / patch file formats are essentially unstandardized. Shouldn't there be an RFC or something?

pjtr | 5 years ago

I hope someone somewhere is compiling this kind of material for the Foundation time capsule.

gglitch | 5 years ago

After reading the man page for diff and the -e option, I found that they actually generate the diff hunks from the end of the file to the beginning in order to keep the start line numbers consistent. I wonder why the other diff formats decided to do it the other way around (from beginning to end)? Doing it from end to beginning actually makes it easier to apply individual hunks without having to regenerate the diff after applying one (assuming you start with a later hunk before applying earlier ones).

u801e | 5 years ago

That was quite refreshing to read. It's funny how little thought I'd given to such a vital tool

I had a good chuckle at 'given a choice between "system with no battery" and "system with systemd" it's no contest'

anitil | 5 years ago

patch: hey everybody look at javascript it has two nulls. wat lol

javascript: at least my nulls aren't like midnight, january 1, 1970

unix: damn js that's an epoch burn

jancsika | 5 years ago