[Dev] Re: embarrassing patch question

James Manning dev@trilug.org
Thu, 28 Feb 2002 12:32:32 -0500


[David Filion]
> 1.1 Create the patch
> 	diff -c -b -r /original /new > filename.patch
> 
> diff options:
> 	-c  Produces a listing of differences with three lines of context.
> 	-b  Ignores trailing blanks (spaces and tabs) and treats other strings
> 	    of blanks as equivalent.
> 	-r  Applies diff recursively to common subdirectories encountered.
> 
> 1.2 Apply the patch
> 	patch -c -l -p1 -d /original < filename.patch

I'd leave out this section personally - mainly just cuz I'm a big
fan of unified diffs and anything that helps ppl avoid the older
versions is a Good Thing IMHO :)

> 2.0 Using newer/GNU diff and patch utilities.
> 	Unlike their older counterparts, the newer/GNU versions of diff 
> 	understand the unified format of patch file.  This is the format used
> 	by the Linux kernel developers.

... and most other Free Software projects, AFAICT :)

> diff options:
> 	-u  Output (default 2) lines of unified context.

default's been 3 for as long as I can remember - prob. just a typo?

> patch options:
> 	-p NUM  Strip NUM leading components from file names.

This is really the key point ppl need to understand in my exp.

> 3.0 Creating a patch using CVS.
> 	A patch is created in CVS using the rdiff cvs command.

"cvs diff" works well for local mods, like for checking before
a commit (to make sure you're not commit'ing things you don't
want to).  In many cases you don't want to diff against two
things that are checked in, but against local mods to a branch.

> 3.1 Create the patch.
> 	
> 	o Create a context (default) format diff of release tags rel1 and 
> 	  rel2 for module.
> 	cvs rdiff -r rel1 -r rel2 module
> 
> 	o Create a unidiff format diff of release tags rel1 and rel2 
> 	for module.
> 	cvs rdiff -u -r rel1 -r rel2 module

Pedantic, but for the sake of consistency it's prob. woth including
the "> filename.patch" part for clarity.

Great doc!  Wish I had it around back when I was learning diff/patch :)

James
-- 
James Manning <jmm@sublogic.com>
GPG Key fingerprint = B913 2FBD 14A9 CE18 B2B7  9C8E A0BF B026 EEBB F6E4