[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Reading and applying patches



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chong Yu Meng wrote:
> Hi all,
> 
> I'm having some difficulty understanding patching in general. A
> little background: I downloaded the source tarball for a program and
> it will not "make" cleanly. Checking the forum on the website,
> someone had published a patch in the form of text in an email that
> looks like this:
> 
> --- mlrate/mlrate.c 2003-01-27 10:31:31.000000000 +0100 
> +++ mlrate.new/mlrate.c 2004-11-22 12:37:52.086783325 +0100 
> @@ -25,6 +25,8 @@ 
> #include <string.h> 
> ... and continues for a bit longer
> 
> I assume that I should copy and paste the text into a separate file
> and save it. But how do I apply the patch to the source file, which
> is mlrate.c? 

You assume correctly.  mlrate.c refers to a file in the tarball you
are patching.

To apply this patch you would use the patch program.  Usage is
something like this:

cd /where/your/mlrate/tarball/is/
patch -p1 < /path/to/your/saved/patch

The -p1 option tells patch to strip off the first directory when
looking for the file(s) to patch.  So if you have a diff that starts
with "--- mlrate/mlrate.c" and you're in the directory where mlrate.c
is, -p1 would remove the mlrate/ part from the diff and find the file
to patch properly.

> Also, how do I read the file? From some patch files I have come
> across, they have "pluses" and "minuses" and other notation. What do
> they mean?

Lines beginning with a plus are being added by the patch, lines with a
minus are being removed.  The lines that start with either 3 minuses
or plusses indicate the path of file that's being patched.

> Can someone point me to some URLs where I can understand more about
> these patch files? 

I'm sure there are some good tuturials on diffing and patching, but I
don't have any links handy.  Most of the little that I know I picked
up here and there over the years.  You might find the diffutils manual
useful though.

    http://www.gnu.org/software/diffutils/manual/html_node/index.html

- -- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
======================================================================
water, taken in moderation, cannot hurt anybody.
    -- mark twain

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iQFDBAEBAgAtBQJE/Q7VJhhodHRwOi8vd3d3LnBvYm94LmNvbS9+dG16L3BncC90
bXouYXNjAAoJEEMlk4u+rwzjUgYIAIJtSjr6yiyPJwsEPT8wq2XkFNGm0T4LIsYu
RHShhHtuddJtFCBvfOwuinMLujp/BzZdv5FHHrUa2LBqlwvYAW7YP0UjJ3llmgdj
ZiSQi6O1erc79Wo/1wwB35FKDIpEWidApGwHMmmUxTq6DkL5mkK2tZkmV0Yl4yGx
3ojwOrkRmBR09RZxsNvE2A46zchJwVw22mlwXbDCpjVNJTxm9R6CMkJ5nhTybngu
lFWhZ8OOZ3VTSA+6QmOnOOOw6pBxtGEqjaGWT07vVQozj3OOpHiQzfni4iqw1Kks
bAZhSvBdNZsAVYhGTbN/oeLWltgb/ImwX0uRUBym+Fy1iO/p0XE=
=FxpN
-----END PGP SIGNATURE-----


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]