123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <style type="text/css">
- @import url('../css/main.css');
- </style>
- <title>
- Libreboot documentation: using diff and patch
- </title>
- </head>
- <body>
- <div class="section">
- <h1 id="pagetop">Diff and patch</h1>
- <p>This is just a quick guide for reference, use 'man' to know more.</p>
- <p>
- <a href="index.html">Back to index</a>
- </p>
- </div>
- <div class="section">
- <h1>
- Apply a patch
- </h1>
- <p class="important">
- To apply a patch to a single file, do that in it's directory:<br/>
- <b>$ patch < foo.patch</b>
- </p>
- <p>
- Assuming that the patch is distributed in unified format identifying
- the file the patch should be applied to, the above will work. Otherwise:<br/>
- <b>$ patch foo.txt < bar.patch</b>
- </p>
- <p>
- You can apply a patch to an entire directory, but note the "p level".
- What this means is that inside patch files will be the files that you
- intend to patch, identified by path names that might be different
- when the files ane located on your own computer instead of on the computer
- where the patch was created. 'p' level instructs the 'patch' utility to
- ignore parts of the path name to identify the files correctly. Usually a
- p level of 1 will work, so you would use:<br/>
- <b>$ patch -p1 < baz.patch</b>
- </p>
- <p>
- Change to the top level directory before running this. If a patch level
- of 1 cannot identify the files to patch, then inspect the patch file for file names.
- For example:<br/>
- <b>/home/user/do/not/panic/yet.c</b>
- </p>
- <p>
- and you are working in a directory that contains panic/yet.c, use:<br/>
- <b>$ patch -p5 < baz.patch</b>
- </p>
- <p>
- You usually count one up for each path separator (forward slash)
- removed from the beginning of the path, until you are left with a path
- that exists in the current working directory. The count is the p level.
- </p>
- <p>
- Removing a patch using the -R flag<br/>
- <b>$ patch -p5 -R < baz.patch</b>
- </p>
- <p><a href="#pagetop">Back to top of page.</a></p>
-
- </div>
- <div class="section">
- <h1>
- Create a patch with diff
- </h1>
- <p>
- Diff can create a patch for a single file:<br/>
- <b>$ diff -u original.c new.c > original.patch</b>
- </p>
- <p>
- For diff'ing a source tree:<br/>
- <b>$ cp -R original new</b>
- </p>
- <p>
- Do whatever you want in new/ and then diff it:<br/>
- <b>$ diff -rupN original/ new/ > original.patch</b>
- </p>
- <p><a href="#pagetop">Back to top of page.</a></p>
-
- </div>
- <div class="section">
- <h1>
- git diff
- </h1>
- <p>
- git is something special.
- </p>
- <p>
- Note: this won't show new files created.
- </p>
- <p>
- Just make whatever changes you want to a git clone and then:<br/>
- <b>$ git diff > patch.git</b>
- </p>
- <p>
- Note the git revision that you did this with:<br/>
- <b>$ git log</b>
- </p>
-
- <p>
- Alternatively (better yet), commit your changes and then use:<br/>
- $ <b>git format-patch -N</b><br/>
- Replace N with the number of commits that you want to show.
- </p>
- <p><a href="#pagetop">Back to top of page.</a></p>
-
- </div>
- <div class="section">
- <h1>
- git apply
- </h1>
- <p>it really is.</p>
- <p>
- Now to apply that patch in the future, just git clone it again and do
- with the git revision you found from above:<br/>
- <b>$ git reset --hard REVISIONNUMBER</b>
- </p>
- <p>
- Now put patch.git in the git clone directory and do:<br/>
- <b>$ git apply patch.git</b>
- </p>
-
- <p>
- If you use a patch from git format-patch, then use <b>git am patch.git</b> instead of <b>git apply patch.git</b>. git-am
- will re-create the commits aswell, instead of just applying the patch.
- </p>
- <p><a href="#pagetop">Back to top of page.</a></p>
-
- </div>
- <div class="section">
- <p>
- Copyright © 2014, 2015 Francis Rowe <info@gluglug.org.uk><br/>
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
- A copy of the license can be found at <a href="../gfdl-1.3.txt">../gfdl-1.3.txt</a>
- </p>
- <p>
- Updated versions of the license (when available) can be found at
- <a href="https://www.gnu.org/licenses/licenses.html">https://www.gnu.org/licenses/licenses.html</a>
- </p>
- <p>
- UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
- EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
- AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
- ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
- IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
- WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
- PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
- ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
- KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
- ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
- </p>
- <p>
- TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
- TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
- NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
- INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
- COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
- USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
- ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
- DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
- IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
- </p>
- <p>
- The disclaimer of warranties and limitation of liability provided
- above shall be interpreted in a manner that, to the extent
- possible, most closely approximates an absolute disclaimer and
- waiver of all liability.
- </p>
-
- </div>
- </body>
- </html>
|