[BACK]Return to patch.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / patch

Annotation of src/usr.bin/patch/patch.1, Revision 1.9

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