Squirrel Logo

Version Control with makepatch

Listing 1: How diff and patch Work
Johan Vromans
Articles


The diff program compares two versions of a document, generating a set of differences that reflect the changes that need to be applied to the old document to make it identical to the new document.

A typical Unix command might look like this:

       diff -c orig/document document > diff-set 

This assumes that document is the revised version, and that the original version resides in directory orig.

The set of differences can be transported to someone who has the original copy of the document. By running the patch program, the document contents can be updated to the new version:

   patch < diff-set 

The document will be updated, and the original document saved under a different name, usually document.orig.

Note that the concept of patching is in no way restricted to textual documents like program sources and Web pages. It can be applied to virtually anything: books, programs, spreadsheets, and even sound and video files. On the PDP-11, a special tool called SIPP (Save Image Patch Program) was provided by the vendor, and operating system updates were issued as patches to be applied using this program. Modern video compression techniques are based on constructing the next image out of previous images by changing whatever was modified. In any given scene, most of the pixels stay the same from one image to the next, which is why video can be compressed so much.



© Copyright 2003-2018 Johan Vromans. All Rights Reserved.
articles/tpj0403-0016a.html last modified 21:55:22 10-May-2004