1 #define _PAGE_ How To Work With Patches
4 When we speak of 'patches' in the Rockbox project, we mean a set of changes
5 to one or more source files.
7 <h2>Tools Of The Trade</h2>
9 Use the tools 'diff' and 'patch'. Preferably the GNU versions. They're readily
10 available for all imaginable platforms.
14 <li> <a href="http://www.fsf.org/software/patch/patch.html">http://www.fsf.org/software/patch/patch.html</a>
15 <li> <a href="http://www.gnu.org/directory/diffutils.html">http://www.gnu.org/directory/diffutils.html</a>
16 <li> <a href="http://gnuwin32.sourceforge.net/packages/patch.htm">http://gnuwin32.sourceforge.net/packages/patch.htm</a> - patch for Windows
17 <li> <a href="http://gnuwin32.sourceforge.net/packages/diffutils.htm">http://gnuwin32.sourceforge.net/packages/diffutils.htm</a> - diff for Windows
22 These tools will assume and operate on "unix-style" newlines. That means all
23 files that you're diffing and patching etc must have LF newlines only, and
24 <b>not</b> the Windows/DOS standard CRLF newlines,
26 Not complying to this simple fact will cause you grief. Mark my words.
28 <h2>Creating A Patch</h2>
30 We generate diffs (often called patches) using 'diff' in a manner similar to
33 diff -u oldfile newfile > patch
36 People who have checked out code with CVS can do diffs using cvs like this:
38 cvs diff -u file > patch
41 'diff' can also be used on a whole directory etc to generate one file with
42 changes done to multiple:
44 diff -u olddir newdir > patch
47 The -u option means the output is using the 'unified diff' format. Older
48 diff programs don't have that, and then -c (for 'context diff') is OK.
50 <h2>Submitting A Patch</h2>
52 <p>All patches that are meant for inclusion in the sources should follow the
53 format listed on the <a href="contributing.html">Contributing to Rockbox</a>
54 page, and be posted to the <a
55 href="http://sourceforge.net/tracker/?group_id=44306&atid=439120">patch
56 tracker</a>. Patches sent to the mailing list are quickly lost in the traffic
60 Please keep in mind that not all submitted patches will be accepted.
62 <h2>Applying A Patch</h2>
64 Applying a 'patch' (output from diff -u) is done with the 'patch' tool:
70 patch knows that the patchfile is a set of changes on one or more files, and
71 will do those to your local files. If your files have changed too much for the
72 patch to work, it will save the sections of the patch that aren't possible to
73 apply in a file called "filename.rej" (filename being the name of the file for
74 which the failing section was intended for). Then you must take care of them
78 If there is path information in the patchfile that you want to cut off
79 from the left, tell patch how many directory levels to cut off to find the
80 names in your file system:
86 ... each example line removes one extra level of dir info from the left.
88 You can use the --dry-run option to patch to make sure that the patch applies
89 clean. It doesn't actually apply the patch, only prints what would happen if
91 <h2>Removing A Patch</h2>
93 You can remove a patch again from the sources by doing the reverse action of
94 a specific patch. You do this with the -R (or --reverse) options, such as:
96 patch -p1 -R < patchfile