blob: 18c90e94a3cfaaac7532bcefd10bda0604091cae [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano5f327762006-03-02 09:14:516<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-apply(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-apply(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-apply -
269 Apply patch on a git index file and a work tree
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
276<div class="content"><em>git-apply</em> [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
Junio C Hamano6b2cee12006-08-26 08:43:31277 [--no-add] [--index-info] [--allow-binary-replacement | --binary]
278 [-R | --reverse] [--reject] [-z] [-pNUM] [-CNUM] [--inaccurate-eof]
279 [--whitespace=&lt;nowarn|warn|error|error-all|strip&gt;] [--exclude=PATH]
280 [--cached] [--verbose] [&lt;patch&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23281</div>
282<h2>DESCRIPTION</h2>
283<div class="sectionbody">
284<p>Reads supplied diff output and applies it on a git index file
285and a work tree.</p>
286</div>
287<h2>OPTIONS</h2>
288<div class="sectionbody">
289<dl>
290<dt>
291&lt;patch&gt;&#8230;
292</dt>
293<dd>
294<p>
295 The files to read patch from. <em>-</em> can be used to read
296 from the standard input.
297</p>
298</dd>
299<dt>
300--stat
301</dt>
302<dd>
303<p>
304 Instead of applying the patch, output diffstat for the
305 input. Turns off "apply".
306</p>
307</dd>
308<dt>
309--numstat
310</dt>
311<dd>
312<p>
313 Similar to --stat, but shows number of added and
314 deleted lines in decimal notation and pathname without
315 abbreviation, to make it more machine friendly. Turns
316 off "apply".
317</p>
318</dd>
319<dt>
320--summary
321</dt>
322<dd>
323<p>
324 Instead of applying the patch, output a condensed
325 summary of information obtained from git diff extended
326 headers, such as creations, renames and mode changes.
327 Turns off "apply".
328</p>
329</dd>
330<dt>
331--check
332</dt>
333<dd>
334<p>
335 Instead of applying the patch, see if the patch is
336 applicable to the current work tree and/or the index
337 file and detects errors. Turns off "apply".
338</p>
339</dd>
340<dt>
341--index
342</dt>
343<dd>
344<p>
345 When --check is in effect, or when applying the patch
346 (which is the default when none of the options that
347 disables it is in effect), make sure the patch is
348 applicable to what the current index file records. If
349 the file to be patched in the work tree is not
350 up-to-date, it is flagged as an error. This flag also
351 causes the index file to be updated.
352</p>
353</dd>
354<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31355--cached
356</dt>
357<dd>
358<p>
359 Apply a patch without touching the working tree. Instead, take the
360 cached data, apply the patch, and store the result in the index,
361 without using the working tree. This implies <em>--index</em>.
362</p>
363</dd>
364<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23365--index-info
366</dt>
367<dd>
368<p>
369 Newer git-diff output has embedded <em>index information</em>
370 for each blob to help identify the original version that
371 the patch applies to. When this flag is given, and if
372 the original version of the blob is available locally,
373 outputs information about them to the standard output.
374</p>
375</dd>
376<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31377-R, --reverse
378</dt>
379<dd>
380<p>
381 Apply the patch in reverse.
382</p>
383</dd>
384<dt>
385--reject
386</dt>
387<dd>
388<p>
389 For atomicity, <a href="git-apply.html">git-apply(1)</a> by default fails the whole patch and
390 does not touch the working tree when some of the hunks
391 do not apply. This option makes it apply
Junio C Hamano9adfc6a2006-08-28 07:18:38392 the parts of the patch that are applicable, and leave the
393 rejected hunks in corresponding *.rej files.
Junio C Hamano6b2cee12006-08-26 08:43:31394</p>
395</dd>
396<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23397-z
398</dt>
399<dd>
400<p>
401 When showing the index information, do not munge paths,
402 but use NUL terminated machine readable format. Without
403 this flag, the pathnames output will have TAB, LF, and
404 backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
405 respectively.
406</p>
407</dd>
408<dt>
Junio C Hamano8af15b02006-02-01 00:59:26409-p&lt;n&gt;
410</dt>
411<dd>
412<p>
413 Remove &lt;n&gt; leading slashes from traditional diff paths. The
414 default is 1.
415</p>
416</dd>
417<dt>
Junio C Hamano54559c82006-04-13 07:45:12418-C&lt;n&gt;
419</dt>
420<dd>
421<p>
422 Ensure at least &lt;n&gt; lines of surrounding context match before
423 and after each change. When fewer lines of surrounding
Junio C Hamano33db4372006-06-07 19:51:45424 context exist they all must match. By default no context is
Junio C Hamano54559c82006-04-13 07:45:12425 ever ignored.
426</p>
427</dd>
428<dt>
Junio C Hamano3eb513f2006-09-18 02:47:16429--unidiff-zero
430</dt>
431<dd>
432<p>
433 By default, <a href="git-apply.html">git-apply(1)</a> expects that the patch being
434 applied is a unified diff with at least one line of context.
435 This provides good safety measures, but breaks down when
436 applying a diff generated with --unified=0. To bypass these
437 checks use <em>--unidiff-zero</em>.
438</p>
439<p>Note, for the reasons stated above usage of context-free patches are
440discouraged.</p>
441</dd>
442<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23443--apply
444</dt>
445<dd>
446<p>
Junio C Hamano6b2cee12006-08-26 08:43:31447 If you use any of the options marked "Turns off
448 <em>apply</em>" above, <a href="git-apply.html">git-apply(1)</a> reads and outputs the
Junio C Hamano1a4e8412005-12-27 08:17:23449 information you asked without actually applying the
450 patch. Give this flag after those flags to also apply
451 the patch.
452</p>
453</dd>
454<dt>
455--no-add
456</dt>
457<dd>
458<p>
459 When applying a patch, ignore additions made by the
460 patch. This can be used to extract common part between
461 two files by first running <tt>diff</tt> on them and applying
462 the result with this option, which would apply the
463 deletion part but not addition part.
464</p>
465</dd>
466<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31467--allow-binary-replacement, --binary
Junio C Hamano1a4e8412005-12-27 08:17:23468</dt>
469<dd>
470<p>
Junio C Hamanofd73d892006-09-14 07:38:22471 Historically we did not allow binary patch applied
472 without an explicit permission from the user, and this
473 flag was the way to do so. Currently we always allow binary
474 patch application, so this is a no-op.
Junio C Hamano1a4e8412005-12-27 08:17:23475</p>
476</dd>
Junio C Hamano5f327762006-03-02 09:14:51477<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31478--exclude=&lt;path-pattern&gt;
479</dt>
480<dd>
481<p>
482 Don't apply changes to files matching the given path pattern. This can
483 be useful when importing patchsets, where you want to exclude certain
484 files or directories.
485</p>
486</dd>
487<dt>
Junio C Hamano5f327762006-03-02 09:14:51488--whitespace=&lt;option&gt;
489</dt>
490<dd>
491<p>
492 When applying a patch, detect a new or modified line
493 that ends with trailing whitespaces (this includes a
494 line that solely consists of whitespaces). By default,
495 the command outputs warning messages and applies the
496 patch.
Junio C Hamano6b2cee12006-08-26 08:43:31497 When <a href="git-apply.html">git-apply(1)</a> is used for statistics and not applying a
Junio C Hamano5f327762006-03-02 09:14:51498 patch, it defaults to <tt>nowarn</tt>.
499 You can use different <tt>&lt;option&gt;</tt> to control this
Junio C Hamano341071d2006-06-04 07:24:48500 behavior:
Junio C Hamano5f327762006-03-02 09:14:51501</p>
502<ul>
503<li>
504<p>
505<tt>nowarn</tt> turns off the trailing whitespace warning.
506</p>
507</li>
508<li>
509<p>
510<tt>warn</tt> outputs warnings for a few such errors, but applies the
511 patch (default).
512</p>
513</li>
514<li>
515<p>
516<tt>error</tt> outputs warnings for a few such errors, and refuses
517 to apply the patch.
518</p>
519</li>
520<li>
521<p>
522<tt>error-all</tt> is similar to <tt>error</tt> but shows all errors.
523</p>
524</li>
525<li>
526<p>
527<tt>strip</tt> outputs warnings for a few such errors, strips out the
528 trailing whitespaces and applies the patch.
529</p>
530</li>
531</ul>
532</dd>
Junio C Hamano6b2cee12006-08-26 08:43:31533<dt>
534--inacurate-eof
535</dt>
536<dd>
537<p>
538 Under certain circumstances, some versions of diff do not correctly
539 detect a missing new-line at the end of the file. As a result, patches
540 created by such diff programs do not record incomplete lines
541 correctly. This option adds support for applying such patches by
542 working around this bug.
543</p>
544</dd>
545<dt>
546--verbose
547</dt>
548<dd>
549<p>
550 Report progress to stderr. By default, only a message about the
551 current patch being applied will be printed. This option will cause
552 additional information to be reported.
553</p>
554</dd>
Junio C Hamano5f327762006-03-02 09:14:51555</dl>
556</div>
557<h2>Configuration</h2>
558<div class="sectionbody">
559<dl>
560<dt>
561apply.whitespace
562</dt>
563<dd>
564<p>
565 When no <tt>--whitespace</tt> flag is given from the command
566 line, this configuration item is used as the default.
567</p>
568</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23569</dl>
570</div>
571<h2>Author</h2>
572<div class="sectionbody">
573<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
574</div>
575<h2>Documentation</h2>
576<div class="sectionbody">
577<p>Documentation by Junio C Hamano</p>
578</div>
579<h2>GIT</h2>
580<div class="sectionbody">
581<p>Part of the <a href="git.html">git(7)</a> suite</p>
582</div>
583<div id="footer">
584<div id="footer-text">
Junio C Hamanod97409f2006-10-03 08:41:56585Last updated 03-Oct-2006 08:40:51 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23586</div>
587</div>
588</body>
589</html>