Re: Reading and applying patches



On 05Sep2006 01:44, Todd Zullinger <tmz@xxxxxxxxx> wrote:
| Chong Yu Meng wrote:
| > --- 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.

It's worth mentioning that patch is pretty forgiving. You can usually
save the entire message to a file; patch is happy to skip past the leading
text up to the actual patch data (the output of a diff command, btw).

[...]
| > 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.

Also "!" prefixes lines in both parts that replace each other; the "+"
and "-" prefixes are where lines are removes or added respectively
without any new (or old, respectively) text.

Patch understands output from diff(1), which comes in three basic flavours:

- original diff (rarely used) which is actually a set of ed(1)
commands to turn the old files into the new file.

- context diff, as produced by "diff -c", which is more human readable,
surrounding the changed lines with some unchanged lines from the files.
This also has the advantage or permitting patch to cope a bit with
mismatches. For example, if you have a diff between versions 1.21
and 1.22, and you're trying to apply it to 1.20; if the files are
similar enough patch can use the context lines to guess where the
patch should go.

- unified diff, as produced by "diff -U", which is a more compact form
of context diff, and just as human readable, if not more so.

Make yourself a text file (eg a copy of this message). Then copy it and
modify the copy in various ways. Then compare the two using "diff -U".

A larger patch will normally be made from two complete source trees (the
old and the new) by running diff with the -r option (recursive) which
produces diffs for all the changes files.

For program version change patches, often the "old" tree will be inside
some source control system instead of being a real distinct directory
tree. Commands like "cvs diff" will generate diff output, comparing your
working area against the version inside the system.

Cheers,
--
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

[He] is the only man I know who would regard a naked, beautiful woman staring
deep into his eyes as an uncomplaining audience for his views on the latest
version of the twm window manager. - igb@xxxxxxxxxxxxx (Ian G Batten)

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Re: [PATCH] anobjrmap 9 priority mjb tree
    ... This patch is an attempt at reducing the contention on i_shared_sem ... compile time with and without this patch did not change much, ... * already present in an i_mmaptree without modifying the tree. ... diff -puN kernel/fork.c~010_sem_contention kernel/fork.c ...
    (Linux-Kernel)
  • Re: [PATCH] anobjrmap 9 priority mjb tree
    ... This patch is another attempt at reducing the contention on i_shared_sem. ... * old vma to an i_mmap tree. ... diff -puN kernel/fork.c~110_sem_contention kernel/fork.c ...
    (Linux-Kernel)
  • Success! was Re: tvtime audio vs pcHDTV-3000 card and pvHDTV-1.6 software
    ... On Wednesday 16 March 2005 20:15, Gene Heskett wrote: ... > that a diff actually outputs only the src code differences, ... nor in that simple little 10 line patch that ... >Unforch, the 2.6.11 plain tree has not, in this case been built yet ...
    (Linux-Kernel)
  • Re: how to compile and install a new driver
    ... Warren Block wrote: ... but you'd better include enough info so that they could make FreeBSD-stype diffs: diff has the unfortunate default of making an output that is compatible with ed. ... This supplies extremely little information to use, in case the file you're trying to patch with that diff has changed, and is also damned hard for mere humans to understand. ... then you can compile. ...
    (freebsd-questions)
  • [PATCH][CFT] mm swapping improvements
    ... Nikita's patches and one of my own, and backs out the RSS limit patch ... diff -puN include/linux/mmzone.h~rollup include/linux/mmzone.h ... -int FASTCALL); ...
    (Linux-Kernel)