Annotation of src/usr.bin/patch/patch.1, Revision 1.21
1.21 ! jmc 1: .\" $OpenBSD: patch.1,v 1.20 2007/05/31 19:20:14 jmc Exp $
1.6 jmc 2: .\" Copyright 1986, Larry Wall
3: .\"
4: .\" Redistribution and use in source and binary forms, with or without
5: .\" modification, are permitted provided that the following condition
6: .\" is met:
7: .\" 1. Redistributions of source code must retain the above copyright
8: .\" notice, this condition and the following disclaimer.
1.7 deraadt 9: .\"
1.6 jmc 10: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
11: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
14: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
15: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
16: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
17: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
19: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20: .\" SUCH DAMAGE.
21: .\"
1.21 ! jmc 22: .Dd $Mdocdate: May 31 2007 $
1.9 jmc 23: .Dt PATCH 1
24: .Os
25: .Sh NAME
26: .Nm patch
27: .Nd apply a diff file to an original
28: .Sh SYNOPSIS
29: .Nm patch
1.18 sobrado 30: .Bk -words
31: .Op Fl bCcEeflNnRstuv
32: .Op Fl B Ar backup-prefix
33: .Op Fl D Ar symbol
34: .Op Fl d Ar directory
35: .Op Fl F Ar max-fuzz
36: .Op Fl i Ar patchfile
37: .Op Fl o Ar out-file
38: .Op Fl p Ar strip-count
39: .Op Fl r Ar rej-name
40: .Op Fl V Cm t | nil | never
41: .Op Fl x Ar number
42: .Op Fl z Ar backup-ext
43: .Op Fl Fl posix
1.9 jmc 44: .Op Ar origfile Op Ar patchfile
1.18 sobrado 45: .Ek
1.9 jmc 46: .Nm patch
47: .Pf \*(Lt Ar patchfile
48: .Sh DESCRIPTION
49: .Nm
1.1 deraadt 50: will take a patch file containing any of the four forms of difference
51: listing produced by the
1.9 jmc 52: .Xr diff 1
53: program and apply those differences to an original file,
54: producing a patched version.
1.1 deraadt 55: If
1.9 jmc 56: .Ar patchfile
1.17 millert 57: is omitted, or is a hyphen, the patch will be read from the standard input.
1.9 jmc 58: .Pp
59: .Nm
1.17 millert 60: will attempt to determine the type of the diff listing, unless over-ruled by a
1.9 jmc 61: .Fl c ,
62: .Fl e ,
63: .Fl n ,
1.1 deraadt 64: or
1.9 jmc 65: .Fl u
1.11 millert 66: option.
1.1 deraadt 67: Context diffs (old-style, new-style, and unified) and
1.17 millert 68: normal diffs are applied directly by the
1.9 jmc 69: .Nm
1.17 millert 70: program itself, whereas ed diffs are simply fed to the
1.9 jmc 71: .Xr ed 1
1.1 deraadt 72: editor via a pipe.
1.9 jmc 73: .Pp
1.17 millert 74: If the
75: .Ar patchfile
76: contains more than one patch,
1.9 jmc 77: .Nm
1.1 deraadt 78: will try to apply each of them as if they came from separate patch files.
79: This means, among other things, that it is assumed that the name of the file
1.17 millert 80: to patch must be determined for each diff listing, and that the garbage before
81: each diff listing will be examined for interesting things such as file names
82: and revision level (see the section on
83: .Sx Filename Determination
84: below).
1.9 jmc 85: .Pp
1.11 millert 86: The options are as follows:
1.9 jmc 87: .Bl -tag -width Ds
1.18 sobrado 88: .It Xo
89: .Fl B Ar backup-prefix ,
90: .Fl Fl prefix Ar backup-prefix
91: .Xc
92: Causes the next argument to be interpreted as a prefix to the backup file
93: name.
94: If this argument is specified, any argument to
95: .Fl z
96: will be ignored.
1.12 millert 97: .It Fl b , Fl Fl backup
98: Save a backup copy of the file before it is modified.
99: By default the original file is saved with a backup extension of
100: .Qq .orig
101: unless the file already has a numbered backup, in which case a numbered
102: backup is made.
103: This is equivalent to specifying
1.18 sobrado 104: .Qo Fl V Cm existing Qc .
1.12 millert 105: This option is currently the default but that will change in a future release.
1.18 sobrado 106: .It Fl C , Fl Fl check
107: Checks that the patch would apply cleanly, but does not modify anything.
1.9 jmc 108: .It Fl c , Fl Fl context
109: Forces
110: .Nm
1.1 deraadt 111: to interpret the patch file as a context diff.
1.18 sobrado 112: .It Xo
113: .Fl D Ar symbol ,
114: .Fl Fl ifdef Ar symbol
115: .Xc
1.9 jmc 116: Causes
117: .Nm
118: to use the
119: .Qq #ifdef...#endif
120: construct to mark changes.
1.1 deraadt 121: The argument following will be used as the differentiating symbol.
122: Note that, unlike the C compiler, there must be a space between the
1.9 jmc 123: .Fl D
1.1 deraadt 124: and the argument.
1.18 sobrado 125: .It Xo
126: .Fl d Ar directory ,
127: .Fl Fl directory Ar directory
128: .Xc
129: Causes
130: .Nm
1.21 ! jmc 131: to interpret the next argument as a directory,
! 132: and change working directory to it before doing anything else.
1.18 sobrado 133: .It Fl E , Fl Fl remove-empty-files
134: Causes
135: .Nm
136: to remove output files that are empty after the patches have been applied.
137: This option is useful when applying patches that create or remove files.
1.9 jmc 138: .It Fl e , Fl Fl ed
139: Forces
140: .Nm
141: to interpret the patch file as an
142: .Xr ed 1
143: script.
1.18 sobrado 144: .It Xo
145: .Fl F Ar max-fuzz ,
146: .Fl Fl fuzz Ar max-fuzz
147: .Xc
148: Sets the maximum fuzz factor.
149: This option only applies to context diffs, and causes
1.9 jmc 150: .Nm
1.18 sobrado 151: to ignore up to that many lines in looking for places to install a hunk.
152: Note that a larger fuzz factor increases the odds of a faulty patch.
153: The default fuzz factor is 2, and it may not be set to more than
154: the number of lines of context in the context diff, ordinarily 3.
1.9 jmc 155: .It Fl f , Fl Fl force
156: Forces
157: .Nm
1.1 deraadt 158: to assume that the user knows exactly what he or she is doing, and to not
1.9 jmc 159: ask any questions.
160: It assumes the following:
161: skip patches for which a file to patch can't be found;
162: patch files even though they have the wrong version for the
163: .Qq Prereq:
164: line in the patch;
165: and assume that patches are not reversed even if they look like they are.
1.1 deraadt 166: This option does not suppress commentary; use
1.9 jmc 167: .Fl s
1.1 deraadt 168: for that.
1.9 jmc 169: .It Xo
1.18 sobrado 170: .Fl i Ar patchfile ,
171: .Fl Fl input Ar patchfile
1.9 jmc 172: .Xc
1.15 millert 173: Causes the next argument to be interpreted as the input file name
174: (i.e. a patchfile).
175: This option may be specified multiple times.
1.9 jmc 176: .It Fl l , Fl Fl ignore-whitespace
177: Causes the pattern matching to be done loosely, in case the tabs and
1.1 deraadt 178: spaces have been munged in your input file.
179: Any sequence of whitespace in the pattern line will match any sequence
180: in the input file.
181: Normal characters must still match exactly.
182: Each line of the context must still match a line in the input file.
1.9 jmc 183: .It Fl N , Fl Fl forward
184: Causes
185: .Nm
1.1 deraadt 186: to ignore patches that it thinks are reversed or already applied.
187: See also
1.9 jmc 188: .Fl R .
1.18 sobrado 189: .It Fl n , Fl Fl normal
190: Forces
191: .Nm
192: to interpret the patch file as a normal diff.
193: .It Xo
194: .Fl o Ar out-file ,
195: .Fl Fl output Ar out-file
196: .Xc
1.9 jmc 197: Causes the next argument to be interpreted as the output file name.
198: .It Xo
1.18 sobrado 199: .Fl p Ar strip-count ,
200: .Fl Fl strip Ar strip-count
1.9 jmc 201: .Xc
202: Sets the pathname strip count,
203: which controls how pathnames found in the patch file are treated,
204: in case you keep your files in a different directory than the person who sent
1.1 deraadt 205: out the patch.
206: The strip count specifies how many slashes are to be stripped from
207: the front of the pathname.
208: (Any intervening directory names also go away.)
1.17 millert 209: For example, supposing the file name in the patch file was
1.9 jmc 210: .Pa /u/howard/src/blurfl/blurfl.c :
211: .Pp
212: Setting
213: .Fl p Ns Ar 0
214: gives the entire pathname unmodified.
215: .Pp
216: .Fl p Ns Ar 1
1.1 deraadt 217: gives
1.9 jmc 218: .Pp
219: .D1 Pa u/howard/src/blurfl/blurfl.c
220: .Pp
221: without the leading slash.
222: .Pp
223: .Fl p Ns Ar 4
1.1 deraadt 224: gives
1.9 jmc 225: .Pp
226: .D1 Pa blurfl/blurfl.c
227: .Pp
228: Not specifying
229: .Fl p
230: at all just gives you
231: .Pa blurfl.c ,
232: unless all of the directories in the leading path
233: .Pq Pa u/howard/src/blurfl
234: exist and that path is relative,
1.1 deraadt 235: in which case you get the entire pathname unmodified.
236: Whatever you end up with is looked for either in the current directory,
237: or the directory specified by the
1.9 jmc 238: .Fl d
1.11 millert 239: option.
1.9 jmc 240: .It Fl R , Fl Fl reverse
241: Tells
242: .Nm
1.1 deraadt 243: that this patch was created with the old and new files swapped.
244: (Yes, I'm afraid that does happen occasionally, human nature being what it
245: is.)
1.9 jmc 246: .Nm
1.1 deraadt 247: will attempt to swap each hunk around before applying it.
248: Rejects will come out in the swapped format.
249: The
1.9 jmc 250: .Fl R
1.11 millert 251: option will not work with ed diff scripts because there is too little
1.1 deraadt 252: information to reconstruct the reverse operation.
1.9 jmc 253: .Pp
1.1 deraadt 254: If the first hunk of a patch fails,
1.9 jmc 255: .Nm
1.1 deraadt 256: will reverse the hunk to see if it can be applied that way.
257: If it can, you will be asked if you want to have the
1.9 jmc 258: .Fl R
1.11 millert 259: option set.
1.1 deraadt 260: If it can't, the patch will continue to be applied normally.
261: (Note: this method cannot detect a reversed patch if it is a normal diff
262: and if the first command is an append (i.e. it should have been a delete)
263: since appends always succeed, due to the fact that a null context will match
264: anywhere.
265: Luckily, most patches add or change lines rather than delete them, so most
266: reversed normal diffs will begin with a delete, which will fail, triggering
267: the heuristic.)
1.9 jmc 268: .It Xo
1.18 sobrado 269: .Fl r Ar rej-name ,
270: .Fl Fl reject-file Ar rej-name
271: .Xc
272: Causes the next argument to be interpreted as the reject file name.
273: .It Xo
1.9 jmc 274: .Fl s , Fl Fl quiet ,
275: .Fl Fl silent
276: .Xc
277: Makes
278: .Nm
1.1 deraadt 279: do its work silently, unless an error occurs.
1.17 millert 280: .It Fl t , Fl Fl batch
281: Similar to
282: .Fl f ,
283: in that it suppresses questions, but makes some different assumptions:
284: skip patches for which a file to patch can't be found (the same as
285: .Fl f ) ;
286: skip patches for which the file has the wrong version for the
287: .Qq Prereq:
288: line in the patch;
289: and assume that patches are reversed if they look like they are.
1.9 jmc 290: .It Fl u , Fl Fl unified
291: Forces
292: .Nm
1.1 deraadt 293: to interpret the patch file as a unified context diff (a unidiff).
1.18 sobrado 294: .It Xo
295: .Fl V Cm t | nil | never ,
296: .Fl Fl version-control Cm t | nil | never
297: .Xc
1.9 jmc 298: Causes the next argument to be interpreted as a method for creating
299: backup file names.
300: The type of backups made can also be given in the
1.17 millert 301: .Ev PATCH_VERSION_CONTROL
302: or
1.9 jmc 303: .Ev VERSION_CONTROL
1.17 millert 304: environment variables, which are overridden by this option.
1.1 deraadt 305: The
1.9 jmc 306: .Fl B
1.1 deraadt 307: option overrides this option, causing the prefix to always be used for
308: making backup file names.
1.17 millert 309: The values of the
310: .Ev PATCH_VERSION_CONTROL
311: and
1.9 jmc 312: .Ev VERSION_CONTROL
1.17 millert 313: environment variables and the argument to the
1.9 jmc 314: .Fl V
315: option are like the GNU Emacs
316: .Dq version-control
317: variable; they also recognize synonyms that are more descriptive.
318: The valid values are (unique abbreviations are accepted):
319: .Bl -tag -width Ds -offset indent
1.18 sobrado 320: .It Cm t , numbered
1.1 deraadt 321: Always make numbered backups.
1.18 sobrado 322: .It Cm nil , existing
1.9 jmc 323: Make numbered backups of files that already have them,
324: simple backups of the others.
1.18 sobrado 325: .It Cm never , simple
1.1 deraadt 326: Always make simple backups.
1.9 jmc 327: .El
1.18 sobrado 328: .It Fl v , Fl Fl version
329: Causes
330: .Nm
331: to print out its revision header and patch level.
1.9 jmc 332: .It Xo
1.18 sobrado 333: .Fl x Ar number ,
334: .Fl Fl debug Ar number
1.9 jmc 335: .Xc
336: Sets internal debugging flags, and is of interest only to
337: .Nm
1.1 deraadt 338: patchers.
1.18 sobrado 339: .It Xo
340: .Fl z Ar backup-ext ,
341: .Fl Fl suffix Ar backup-ext
342: .Xc
1.12 millert 343: Causes the next argument to be interpreted as the backup extension, to be
344: used in place of
345: .Qq .orig .
1.17 millert 346: .It Fl Fl posix
347: Enables strict
348: .St -p1003.2
349: conformance, specifically:
350: .Bl -enum
351: .It
352: Backup files are not created unless the
353: .Fl b
354: option is specified.
355: .It
356: If unspecified, the file name used is the first of the old, new and
357: index files that exists.
358: .El
359: .El
360: .Ss Patch Application
361: .Nm
362: will try to skip any leading garbage, apply the diff,
363: and then skip any trailing garbage.
364: Thus you could feed an article or message containing a
365: diff listing to
366: .Nm patch ,
367: and it should work.
368: If the entire diff is indented by a consistent amount,
369: this will be taken into account.
370: .Pp
371: With context diffs, and to a lesser extent with normal diffs,
372: .Nm
373: can detect when the line numbers mentioned in the patch are incorrect,
374: and will attempt to find the correct place to apply each hunk of the patch.
375: As a first guess, it takes the line number mentioned for the hunk, plus or
376: minus any offset used in applying the previous hunk.
377: If that is not the correct place,
378: .Nm
379: will scan both forwards and backwards for a set of lines matching the context
380: given in the hunk.
381: First
382: .Nm
383: looks for a place where all lines of the context match.
384: If no such place is found, and it's a context diff, and the maximum fuzz factor
385: is set to 1 or more, then another scan takes place ignoring the first and last
386: line of context.
387: If that fails, and the maximum fuzz factor is set to 2 or more,
388: the first two and last two lines of context are ignored,
389: and another scan is made.
390: .Pq The default maximum fuzz factor is 2.
391: .Pp
392: If
393: .Nm
394: cannot find a place to install that hunk of the patch, it will put the hunk
395: out to a reject file, which normally is the name of the output file plus
396: .Qq .rej .
397: (Note that the rejected hunk will come out in context diff form whether the
398: input patch was a context diff or a normal diff.
399: If the input was a normal diff, many of the contexts will simply be null.)
400: The line numbers on the hunks in the reject file may be different than
401: in the patch file: they reflect the approximate location patch thinks the
402: failed hunks belong in the new file rather than the old one.
403: .Pp
404: As each hunk is completed, you will be told whether the hunk succeeded or
405: failed, and which line (in the new file)
406: .Nm
407: thought the hunk should go on.
408: If this is different from the line number specified in the diff,
409: you will be told the offset.
410: A single large offset MAY be an indication that a hunk was installed in the
411: wrong place.
412: You will also be told if a fuzz factor was used to make the match, in which
413: case you should also be slightly suspicious.
414: .Ss Filename Determination
415: If no original file is specified on the command line,
416: .Nm
417: will try to figure out from the leading garbage what the name of the file
418: to edit is.
419: When checking a prospective file name, pathname components are stripped
420: as specified by the
421: .Fl p
422: option and the file's existence and writability are checked relative
423: to the current working directory (or the directory specified by the
424: .Fl d
425: option).
426: .Pp
427: If the diff is a context or unified diff,
428: .Nm
429: is able to determine the old and new file names from the diff header.
430: For context diffs, the
431: .Dq old
432: file is specified in the line beginning with
433: .Qq ***
434: and the
435: .Dq new
436: file is specified in the line beginning with
437: .Qq --- .
438: For a unified diff, the
439: .Dq old
440: file is specified in the line beginning with
441: .Qq ---
442: and the
443: .Dq new
444: file is specified in the line beginning with
445: .Qq +++ .
446: If there is an
447: .Qq Index:
448: line in the leading garbage (regardless of the diff type),
449: .Nm
450: will use the file name from that line as the
451: .Dq index
452: file.
453: .Pp
454: .Nm
455: will choose the file name by performing the following steps, with the first
456: match used:
457: .Bl -enum
458: .It
459: If
460: .Nm
461: is operating in strict
462: .St -p1003.2
463: mode, the first of the
464: .Dq old ,
465: .Dq new
466: and
467: .Dq index
468: file names that exist is used.
469: Otherwise,
470: .Nm
471: will examine either the
472: .Dq old
473: and
474: .Dq new
475: file names or, for a non-context diff, the
476: .Dq index
477: file name, and choose the file name with the fewest path components,
478: the shortest basename, and the shortest total file name length (in that order).
479: .It
480: If no file exists,
481: .Nm
482: checks for the existence of the files in an SCCS or RCS directory
483: (using the appropriate prefix or suffix) using the criteria specified
484: above.
485: If found,
486: .Nm
487: will attempt to get or check out the file.
488: .It
489: If no suitable file was found to patch, the patch file is a context or
490: unified diff, and the old file was zero length, the new file name is
491: created and used.
492: .It
493: If the file name still cannot be determined,
494: .Nm
495: will prompt the user for the file name to use.
1.9 jmc 496: .El
1.17 millert 497: .Pp
498: Additionally, if the leading garbage contains a
499: .Qq Prereq:\ \&
500: line,
501: .Nm
502: will take the first word from the prerequisites line (normally a version
503: number) and check the input file to see if that word can be found.
504: If not,
505: .Nm
506: will ask for confirmation before proceeding.
507: .Pp
508: The upshot of all this is that you should be able to say, while in a news
509: interface, the following:
510: .Pp
511: .Dl | patch -d /usr/src/local/blurfl
512: .Pp
513: and patch a file in the blurfl directory directly from the article containing
514: the patch.
515: .Ss Backup Files
516: By default, the patched version is put in place of the original, with
517: the original file backed up to the same name with the extension
518: .Qq .orig ,
519: or as specified by the
520: .Fl B ,
521: .Fl V ,
522: or
523: .Fl z
524: options.
525: The extension used for making backup files may also be specified in the
526: .Ev SIMPLE_BACKUP_SUFFIX
527: environment variable, which is overridden by the options above.
528: .Pp
529: If the backup file is a symbolic or hard link to the original file,
530: .Nm
531: creates a new backup file name by changing the first lowercase letter
532: in the last component of the file's name into uppercase.
533: If there are no more lowercase letters in the name,
534: it removes the first character from the name.
535: It repeats this process until it comes up with a
536: backup file that does not already exist or is not linked to the original file.
537: .Pp
538: You may also specify where you want the output to go with the
539: .Fl o
540: option; if that file already exists, it is backed up first.
541: .Ss Notes For Patch Senders
1.1 deraadt 542: There are several things you should bear in mind if you are going to
1.9 jmc 543: be sending out patches:
544: .Pp
545: First, you can save people a lot of grief by keeping a
546: .Pa patchlevel.h
547: file which is patched to increment the patch level as the first diff in the
1.1 deraadt 548: patch file you send out.
1.9 jmc 549: If you put a
550: .Qq Prereq:
551: line in with the patch, it won't let them apply
1.1 deraadt 552: patches out of order without some warning.
1.9 jmc 553: .Pp
1.17 millert 554: Second, make sure you've specified the file names right, either in a
1.9 jmc 555: context diff header, or with an
556: .Qq Index:
557: line.
1.1 deraadt 558: If you are patching something in a subdirectory, be sure to tell the patch
1.4 aaron 559: user to specify a
1.9 jmc 560: .Fl p
1.11 millert 561: option as needed.
1.9 jmc 562: .Pp
1.1 deraadt 563: Third, you can create a file by sending out a diff that compares a
564: null file to the file you want to create.
565: This will only work if the file you want to create doesn't exist already in
566: the target directory.
1.9 jmc 567: .Pp
1.1 deraadt 568: Fourth, take care not to send out reversed patches, since it makes people wonder
569: whether they already applied the patch.
1.9 jmc 570: .Pp
1.1 deraadt 571: Fifth, while you may be able to get away with putting 582 diff listings into
572: one file, it is probably wiser to group related patches into separate files in
573: case something goes haywire.
1.9 jmc 574: .Sh ENVIRONMENT
1.17 millert 575: .Bl -tag -width "PATCH_VERSION_CONTROL" -compact
576: .It Ev POSIXLY_CORRECT
577: When set,
578: .Nm
579: behaves as if the
580: .Fl Fl posix
581: option has been specified.
582: .It Ev SIMPLE_BACKUP_SUFFIX
583: Extension to use for backup file names instead of
584: .Qq .orig .
1.9 jmc 585: .It Ev TMPDIR
586: Directory to put temporary files in; default is
587: .Pa /tmp .
1.17 millert 588: .It Ev PATCH_VERSION_CONTROL
589: Selects when numbered backup files are made.
1.9 jmc 590: .It Ev VERSION_CONTROL
1.17 millert 591: Same as
592: .Ev PATCH_VERSION_CONTROL .
1.9 jmc 593: .El
594: .Sh FILES
1.17 millert 595: .Bl -tag -width "$TMPDIR/patch*" -compact
1.9 jmc 596: .It Pa $TMPDIR/patch*
1.17 millert 597: .Nm
598: temporary files
599: .It Pa /dev/tty
600: used to read input when
601: .Nm
602: prompts the user
1.9 jmc 603: .El
604: .Sh DIAGNOSTICS
1.1 deraadt 605: Too many to list here, but generally indicative that
1.9 jmc 606: .Nm
1.1 deraadt 607: couldn't parse your patch file.
1.9 jmc 608: .Pp
609: The message
610: .Qq Hmm...
611: indicates that there is unprocessed text in the patch file and that
612: .Nm
1.1 deraadt 613: is attempting to intuit whether there is a patch in that text and, if so,
614: what kind of patch it is.
1.9 jmc 615: .Pp
1.13 millert 616: The
1.9 jmc 617: .Nm
1.13 millert 618: utility exits with one of the following values:
619: .Pp
620: .Bl -tag -width Ds -compact -offset indent
621: .It \&0
622: Successful completion.
623: .It \&1
624: One or more lines were written to a reject file.
625: .It \*[Gt]\&1
626: An error occurred.
627: .El
628: .Pp
1.1 deraadt 629: When applying a set of patches in a loop it behooves you to check this
630: exit status so you don't apply a later patch to a partially patched file.
1.9 jmc 631: .Sh SEE ALSO
632: .Xr diff 1
1.19 jmc 633: .Sh STANDARDS
634: The
635: .Nm
636: utility is compliant with the
637: .St -p1003.1-2004
638: specification,
639: but its presence is optional.
640: .Pp
641: The flags
642: .Op Fl CEfstuvBFVxz
643: and
644: .Op Fl -posix
645: are extensions to that specification.
1.9 jmc 646: .Sh AUTHORS
1.13 millert 647: .An Larry Wall
1.9 jmc 648: with many other contributors.
649: .Sh CAVEATS
650: .Nm
1.1 deraadt 651: cannot tell if the line numbers are off in an ed script, and can only detect
1.9 jmc 652: bad line numbers in a normal diff when it finds a
653: .Qq change
654: or a
655: .Qq delete
656: command.
1.1 deraadt 657: A context diff using fuzz factor 3 may have the same problem.
658: Until a suitable interactive interface is added, you should probably do
659: a context diff in these cases to see if the changes made sense.
660: Of course, compiling without errors is a pretty good indication that the patch
661: worked, but not always.
1.9 jmc 662: .Pp
663: .Nm
1.1 deraadt 664: usually produces the correct results, even when it has to do a lot of
665: guessing.
666: However, the results are guaranteed to be correct only when the patch is
667: applied to exactly the same version of the file that the patch was
668: generated from.
1.9 jmc 669: .Sh BUGS
670: Could be smarter about partial matches, excessively deviant offsets and
1.1 deraadt 671: swapped code, but that would take an extra pass.
1.9 jmc 672: .Pp
673: Check patch mode
674: .Pq Fl C
1.3 espie 675: will fail if you try to check several patches in succession that build on
1.9 jmc 676: each other.
1.17 millert 677: The entire
1.9 jmc 678: .Nm
1.17 millert 679: code would have to be restructured to keep temporary files around so that it
680: can handle this situation.
1.9 jmc 681: .Pp
1.1 deraadt 682: If code has been duplicated (for instance with #ifdef OLDCODE ... #else ...
683: #endif),
1.9 jmc 684: .Nm
1.1 deraadt 685: is incapable of patching both versions, and, if it works at all, will likely
686: patch the wrong one, and tell you that it succeeded to boot.
1.9 jmc 687: .Pp
1.1 deraadt 688: If you apply a patch you've already applied,
1.9 jmc 689: .Nm
1.1 deraadt 690: will think it is a reversed patch, and offer to un-apply the patch.
691: This could be construed as a feature.