home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gnu / patch-2.1-bin.lha / GNU / man / cat1 / patch.0
Text File  |  1993-12-07  |  22KB  |  529 lines

  1.  
  2.  
  3.  
  4. PATCH(1)                                                 PATCH(1)
  5.  
  6.  
  7. NNAAMMEE
  8.        patch - apply a diff file to an original
  9.  
  10. SSYYNNOOPPSSIISS
  11.        ppaattcchh [options] [origfile [patchfile]] [+ [options] [orig-
  12.        file]]...
  13.  
  14.        but usually just
  15.  
  16.        ppaattcchh <patchfile
  17.  
  18. DDEESSCCRRIIPPTTIIOONN
  19.        _P_a_t_c_h will take a patch file containing any  of  the  four
  20.        forms  of  difference listing produced by the _d_i_f_f program
  21.        and apply those differences to an original file, producing
  22.        a patched version.  By default, the patched version is put
  23.        in place of the original, with the original file backed up
  24.        to  the  same name with the extension ".orig" ("~" on sys-
  25.        tems that do not support long file names), or as specified
  26.        by  the  --bb  (----ssuuffffiixx),  --BB  (----pprreeffiixx),  or  --VV  (----vveerr--
  27.        ssiioonn--ccoonnttrrooll) options.   The  extension  used  for  making
  28.        backup   files   may   also   be  specified  in  the  SSIIMM--
  29.        PPLLEE__BBAACCKKUUPP__SSUUFFFFIIXX environment variable, which is  overrid-
  30.        den by the above options.
  31.  
  32.        If  the  backup  file  already exists, ppaattcchh creates a new
  33.        backup file name by changing the first lowercase letter in
  34.        the  last component of the file's name into uppercase.  If
  35.        there are no  more  lowercase  letters  in  the  name,  it
  36.        removes  the  first  character  from the name.  It repeats
  37.        this process until it comes up with  a  backup  file  that
  38.        does not already exist.
  39.  
  40.        You  may also specify where you want the output to go with
  41.        a --oo (----oouuttppuutt) option; if that file already exists, it is
  42.        backed up first.
  43.  
  44.        If _p_a_t_c_h_f_i_l_e is omitted, or is a hyphen, the patch will be
  45.        read from standard input.
  46.  
  47.        Upon startup, patch will attempt to determine the type  of
  48.        the  diff  listing, unless over-ruled by a --cc (----ccoonntteexxtt),
  49.        --ee (----eedd), --nn (----nnoorrmmaall), or --uu (----uunniiffiieedd) option.   Con-
  50.        text  diffs (old-style, new-style, and unified) and normal
  51.        diffs are applied by the _p_a_t_c_h program  itself,  while  _e_d
  52.        diffs are simply fed to the _e_d editor via a pipe.
  53.  
  54.        _P_a_t_c_h  will  try  to  skip  any leading garbage, apply the
  55.        diff, and then skip any trailing garbage.  Thus you  could
  56.        feed  an  article  or message containing a diff listing to
  57.        _p_a_t_c_h, and it should work.  If the entire diff is indented
  58.        by a consistent amount, this will be taken into account.
  59.  
  60.        With  context  diffs,  and  to a lesser extent with normal
  61.  
  62.  
  63.  
  64.                               LOCAL                             1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PATCH(1)                                                 PATCH(1)
  71.  
  72.  
  73.        diffs, _p_a_t_c_h can detect when the line numbers mentioned in
  74.        the patch are incorrect, and will attempt to find the cor-
  75.        rect place to apply each hunk of the patch.   As  a  first
  76.        guess,  it  takes  the line number mentioned for the hunk,
  77.        plus or minus any offset used  in  applying  the  previous
  78.        hunk.   If  that is not the correct place, _p_a_t_c_h will scan
  79.        both forwards and backwards for a set  of  lines  matching
  80.        the  context  given  in the hunk.  First _p_a_t_c_h looks for a
  81.        place where all lines of the context match.   If  no  such
  82.        place  is  found, and it's a context diff, and the maximum
  83.        fuzz factor is set to 1 or more, then another  scan  takes
  84.        place  ignoring  the  first  and last line of context.  If
  85.        that fails, and the maximum fuzz factor is  set  to  2  or
  86.        more,  the  first  two  and  last two lines of context are
  87.        ignored, and another scan is made.  (The  default  maximum
  88.        fuzz  factor  is  2.)   If  _p_a_t_c_h  cannot  find a place to
  89.        install that hunk of the patch, it will put the  hunk  out
  90.        to a reject file, which normally is the name of the output
  91.        file plus ".rej" ("#" on systems that do not support  long
  92.        file  names).   (Note that the rejected hunk will come out
  93.        in context diff form whether the input patch was a context
  94.        diff  or  a  normal diff.  If the input was a normal diff,
  95.        many of the contexts will simply be null.)  The line  num-
  96.        bers on the hunks in the reject file may be different than
  97.        in the patch file: they reflect the  approximate  location
  98.        patch  thinks  the  failed  hunks  belong  in the new file
  99.        rather than the old one.
  100.  
  101.        As each hunk is completed, you will be  told  whether  the
  102.        hunk succeeded or failed, and which line (in the new file)
  103.        _p_a_t_c_h thought the hunk should go on.  If this is different
  104.        from  the  line  number  specified in the diff you will be
  105.        told the offset.  A single large offset MAY be an  indica-
  106.        tion  that  a  hunk was installed in the wrong place.  You
  107.        will also be told if a fuzz factor was used  to  make  the
  108.        match,  in  which  case you should also be slightly suspi-
  109.        cious.
  110.  
  111.        If no original file is  specified  on  the  command  line,
  112.        _p_a_t_c_h will try to figure out from the leading garbage what
  113.        the name of the file to edit is.  In the header of a  con-
  114.        text  diff,  the  file  name is found from lines beginning
  115.        with "***" or "---", with the shortest name of an existing
  116.        file  winning.   Only  context diffs have lines like that,
  117.        but if there is an "Index:" line in the  leading  garbage,
  118.        _p_a_t_c_h  will  try to use the file name from that line.  The
  119.        context diff header takes precedence over an  Index  line.
  120.        If  no file name can be intuited from the leading garbage,
  121.        you will be asked for the name of the file to patch.
  122.  
  123.        If the original file cannot be found or is read-only,  but
  124.        a  suitable  SCCS or RCS file is handy, _p_a_t_c_h will attempt
  125.        to get or check out the file.
  126.  
  127.  
  128.  
  129.  
  130.                               LOCAL                             2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PATCH(1)                                                 PATCH(1)
  137.  
  138.  
  139.        Additionally, if the leading garbage contains a "Prereq: "
  140.        line,  _p_a_t_c_h  will  take the first word from the prerequi-
  141.        sites line (normally a version number) and check the input
  142.        file to see if that word can be found.  If not, _p_a_t_c_h will
  143.        ask for confirmation before proceeding.
  144.  
  145.        The upshot of all this is that you should be able to  say,
  146.        while in a news interface, the following:
  147.  
  148.             | patch -d /usr/src/local/blurfl
  149.  
  150.        and patch a file in the blurfl directory directly from the
  151.        article containing the patch.
  152.  
  153.        If the patch file contains more than one patch, _p_a_t_c_h will
  154.        try  to  apply  each of them as if they came from separate
  155.        patch files.  This means, among other things, that  it  is
  156.        assumed  that the name of the file to patch must be deter-
  157.        mined for each diff listing, and that the  garbage  before
  158.        each  diff listing will be examined for interesting things
  159.        such as file names and revision level, as mentioned previ-
  160.        ously.   You  can  give options (and another original file
  161.        name) for the second and subsequent patches by  separating
  162.        the  corresponding argument lists by a '+'.  (The argument
  163.        list for a second or subsequent patch may  not  specify  a
  164.        new patch file, however.)
  165.  
  166.        _P_a_t_c_h recognizes the following options:
  167.  
  168.        --bb ssuuffff,, ----ssuuffffiixx==ssuuffff
  169.             causes  ssuuffff  to  be interpreted as the backup exten-
  170.             sion, to be used in place of ".orig" or "~".
  171.  
  172.        --BB pprreeff,, ----pprreeffiixx==pprreeff
  173.             causes pprreeff to be interpreted  as  a  prefix  to  t