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