[lug] Creating a patch

Scott A. Herod herod at interact-tv.com
Fri Oct 19 11:39:52 MDT 2001


It helps if your original and new versions are at the same level down
from 
a common directory.  Then go to that common directory and run:

diff -Naur path/to/old path/now_to/new > patchfile

You'll get path stuff in each but the person using the patch can
run "patch --strip=2 ... " to strip off those common directories,
in this case 2 of them.

Check the patch man page.  It might also be easy to clean things even
if your leading directories are of different depths.

Scott

Ken Weinert wrote:
> 
>         Anyone got a good pointer to creating a patch for submission
> to the code maintainer? I realize I'll probably need a unified
> diff. I've the original distribution and my changes in separate
> directory trees. The problem I *think* I'm having is that I get
> machine-specific path names in the output.
> 
> I did it like this:
> 
> cd /tmp/gengetopt-2.4/
> 
> diff -u src ~/src/gengetopt-2.4/src > patchfile
> 
> I get the right diffs, but I get lines like:
> 
> diff -u src/gengetopt.h /home/kenw/src/gengetopt-2.4/src/gengetopt.h
> --- src/gengetopt.h     Mon May 14 13:41:34 2001
> +++ /home/kenw/src/gengetopt-2.4/src/gengetopt.h        Fri Oct 19 08:51:56 2001
> 
> in the output.
> 
> I really haven't done patch creation before, and I haven't looked in
> patch files (since they usually just worked I was happy to treat it as
> a black box :) so I don't know if having the diff command in the file
> is OK or if the path name is going to be a problem.
> 
> Thanks for any advice - pointers to a site/sites that explain it
> clearly are also just fine with me.
> 
> --
> Ken Weinert   kenw at ihs.com 303-858-6956 (V) 303-705-4258 (F)
> GnuPG KeyID: 9274F1CE           GnuPG available at http://www.gnupg.org/
> GnuPG Key Fingerprint: 1D87 3720 BB77 4489 A928  79D6 F8EC DD76 9274 F1CE
> Linux 2.2.14: up 24 days,  3:03
> There are two ways to write bug-free code - only the third way works.
> 
>   ------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature



More information about the LUG mailing list