aboutsummaryrefslogtreecommitdiff
path: root/docs/src/misc/patch.texi
blob: cebd7fc408c9d48c3db67cc2f28fa5b0236722e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
\input texinfo
@documentencoding UTF-8

@ifnottex
@paragraphindent 0
@end ifnottex
@titlepage
@title Libreboot documentation: using diff and patch
@end titlepage

@node Top
@top Libreboot documentation: using diff and patch

@menu
* Diff and patch::
* Apply a patch::
* Create a patch with diff::
* git diff::
* git apply::
@end menu

@node Diff and patch
@chapter Diff and patch
@anchor{#diff-and-patch}
This is just a quick guide for reference, use 'man' to know more.

@uref{index.html,Back to index}

@node Apply a patch
@chapter Apply a patch
@anchor{#apply-a-patch}
To apply a patch to a single file, do that in it's directory:@* @strong{$ patch < foo.patch}

Assuming that the patch is distributed in unified format identifying the file the patch should be applied to, the above will work. Otherwise:@* @strong{$ patch foo.txt < bar.patch}

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:@* @strong{$ patch -p1 < baz.patch}

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:@* @strong{/home/user/do/not/panic/yet.c}

and you are working in a directory that contains panic/yet.c, use:@* @strong{$ patch -p5 < baz.patch}

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.

Removing a patch using the -R flag@* @strong{$ patch -p5 -R < baz.patch}

@ref{#pagetop,Back to top of page.}

@node Create a patch with diff
@chapter Create a patch with diff
@anchor{#create-a-patch-with-diff}
Diff can create a patch for a single file:@* @strong{$ diff -u original.c new.c > original.patch}

For diff'ing a source tree:@* @strong{$ cp -R original new}

Do whatever you want in new/ and then diff it:@* @strong{$ diff -rupN original/ new/ > original.patch}

@ref{#pagetop,Back to top of page.}

@node git diff
@chapter git diff
@anchor{#git-diff}
git is something special.

Note: this won't show new files created.

Just make whatever changes you want to a git clone and then:@* @strong{$ git diff > patch.git}

Note the git revision that you did this with:@* @strong{$ git log}

Alternatively (better yet), commit your changes and then use:@* $ @strong{git format-patch -N}@* Replace N with the number of commits that you want to show.

@ref{#pagetop,Back to top of page.}

@node git apply
@chapter git apply
@anchor{#git-apply}
it really is.

Now to apply that patch in the future, just git clone it again and do with the git revision you found from above:@* @strong{$ git reset --hard REVISIONNUMBER}

Now put patch.git in the git clone directory and do:@* @strong{$ git apply patch.git}

If you use a patch from git format-patch, then use @strong{git am patch.git} instead of @strong{git apply patch.git}. git-am will re-create the commits aswell, instead of just applying the patch.

@ref{#pagetop,Back to top of page.}

Copyright © 2014, 2015 Minifree Ltd <info@@minifree.org>@* 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 @uref{../resources/licenses/gfdl-1.3.txt,gfdl-1.3.txt}

Updated versions of the license (when available) can be found at @uref{https://www.gnu.org/licenses/licenses.html,https://www.gnu.org/licenses/licenses.html}

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.

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.

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.

@bye