[H-GEN] using patch

Tony Nugent tony at linuxworks.com.au
Sat Mar 15 07:07:34 EST 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

On Sat Mar 15 2003 at 20:51, Robert Stanford wrote:

> On Sat, 2003-03-15 at 14:51, Edwin Groothuis wrote:
> 
> > They only work with sources which are the same as the original code.
> > They only work if you haven't changed a single line. They only work
> > under these special conditions.
> 
> Then what are these offsets patch often mentions?

When a patch is made with diff, each section has headers that
indicate the line numbers of the start and end/length of the patch.

If a diff is made with -u or -c, then the filenames and dates are
used as headers, and a context around the changed lines is also
included.  patch can use these context lines to adjust the location
of the changes to be exactly where they belong.

This is useful if the document you are patching differs from the one
originally used to take the actual patch.  It can happen (eg, using
a patch from a 2.4.19 kernel and apply it to the 2.4.20 sources),
and when it does, patch warns that yes it did apply the patch, but
at an offset to the original location of the changes.

(I hope this is clear, and what you were referring to:)

Just to add my 2c worth to this thread...

The -u format is very popular, and with -r (recursive) it can be
used to diff sets of files in different directory trees.

Beware that sometimes you need to check to see if the -p switch is
needed to patch... what this does is to strip leading path
components from filenames.  eg, -p2 would strip two leading
directories.  This is useful if you are patching files not in the
same relative path of those that were originally diff'ed.  If patch
complains about missing files, then this might fix that problem.

> Robert Stanford <rob at rotapile.com>

Cheers
Tony

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list