home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / diff-2.3 / diff.info-2 < prev    next >
Encoding:
GNU Info File  |  1993-05-19  |  49.0 KB  |  1,273 lines

  1. This is Info file diff.info, produced by Makeinfo-1.54 from the input
  2. file ./diff.texi.
  3.  
  4.    This file documents the the GNU `diff', `diff3', `sdiff', and `cmp'
  5. commands for showing the differences between text files and the `patch'
  6. command for using their output to update files.
  7.  
  8.    Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided that
  16. the entire resulting derived work is distributed under the terms of a
  17. permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions, except that this permission notice may be stated in a
  22. translation approved by the Foundation.
  23.  
  24. 
  25. File: diff.info,  Node: Line Formats,  Next: Detailed If-then-else,  Prev: Line Group Formats,  Up: If-then-else
  26.  
  27. Line Formats
  28. ------------
  29.  
  30.    Line formats control how each line taken from an input file is
  31. output as part of a line group in if-then-else format.
  32.  
  33.    For example, the following command outputs text with a one-column
  34. change indicator to the left of the text.  The first column of output
  35. is `-' for deleted lines, `|' for added lines, and a space for
  36. unchanged lines.  The formats contain newline characters where newlines
  37. are desired on output.
  38.  
  39.      diff \
  40.         --old-line-format='-%l
  41.      ' \
  42.         --new-line-format='|%l
  43.      ' \
  44.         --unchanged-line-format=' %l
  45.      ' \
  46.         old new
  47.  
  48.    To specify a line format, use one of the following options.  You
  49. should quote FORMAT, since it often contains shell metacharacters.
  50.  
  51. `--old-line-format=FORMAT'
  52.      formats lines just from the first file.
  53.  
  54. `--new-line-format=FORMAT'
  55.      formats lines just from the second file.
  56.  
  57. `--unchanged-line-format=FORMAT'
  58.      formats lines common to both files.
  59.  
  60.    In a line format, ordinary characters represent themselves;
  61. conversion specifications start with `%' and have one of the following
  62. forms.
  63.  
  64. `%l'
  65.      stands for the the contents of the line, not counting its trailing
  66.      newline (if any).  This format ignores whether the line is
  67.      incomplete; *Note Incomplete Lines::.
  68.  
  69. `%L'
  70.      stands for the the contents of the line, including its trailing
  71.      newline (if any).  If a line is incomplete, this format preserves
  72.      its incompleteness.
  73.  
  74. `%0'
  75.      stands for a null character.
  76.  
  77. `%%'
  78.      stands for `%'.
  79.  
  80.    The default line format is `%l' followed by a newline character.
  81.  
  82.    If the input contains tab characters and it is important that they
  83. line up on output, you should ensure that `%l' or `%L' in a line format
  84. is just after a tab stop (e.g. by preceding `%l' or `%L' with a tab
  85. character), or you should use the `-t' or `--expand-tabs' option.
  86.  
  87. 
  88. File: diff.info,  Node: Detailed If-then-else,  Next: Example If-then-else,  Prev: Line Formats,  Up: If-then-else
  89.  
  90. Detailed Description of If-then-else Format
  91. -------------------------------------------
  92.  
  93.    For lines common to both files, `diff' uses the unchanged line group
  94. format.  For each hunk of differences in the merged output format, if
  95. the hunk contains only lines from the first file, `diff' uses the old
  96. line group format; if the hunk contains only lines from the second
  97. file, `diff' uses the new group format; otherwise, `diff' uses the
  98. changed group format.
  99.  
  100.    The old, new, and unchanged line formats specify the output format of
  101. lines from the first file, lines from the second file, and lines common
  102. to both files, respectively.
  103.  
  104.    The option `--ifdef=NAME' is equivalent to the following sequence of
  105. options using shell syntax:
  106.  
  107.      --old-group-format='#ifndef NAME
  108.      %<#endif /* not NAME */
  109.      ' \
  110.      --new-group-format='#ifdef NAME
  111.      %>#endif /* NAME */
  112.      ' \
  113.      --unchanged-group-format='%=' \
  114.      --changed-group-format='#ifndef NAME
  115.      %<#else /* NAME */
  116.      %>#endif /* NAME */
  117.      '
  118.  
  119.    You should carefully check the `diff' output for proper nesting.
  120. For example, when using the the `-D NAME' or `--ifdef=NAME' option, you
  121. should check that if the differing lines contain any of the C
  122. preprocessor directives `#ifdef', `#ifndef', `#else', `#elif', or
  123. `#endif', they are nested properly and match.  If they don't, you must
  124. make corrections manually.  It is a good idea to carefully check the
  125. resulting code anyway to make sure that it really does what you want it
  126. to; depending on how the input files were produced, the output might
  127. contain duplicate or otherwise incorrect code.
  128.  
  129.    The `patch' `-D NAME' option behaves just like the `diff' `-D NAME'
  130. option, except it operates on a file and a diff to produce a merged
  131. file; *Note patch Options::.
  132.  
  133. 
  134. File: diff.info,  Node: Example If-then-else,  Prev: Detailed If-then-else,  Up: If-then-else
  135.  
  136. An Example of If-then-else Format
  137. ---------------------------------
  138.  
  139.    Here is the output of `diff -DTWO lao tzu' (*note Sample diff
  140. Input::., for the complete contents of the two files):
  141.  
  142.      #ifndef TWO
  143.      The Way that can be told of is not the eternal Way;
  144.      The name that can be named is not the eternal name.
  145.      #endif /* not TWO */
  146.      The Nameless is the origin of Heaven and Earth;
  147.      #ifndef TWO
  148.      The Named is the mother of all things.
  149.      #else /* TWO */
  150.      The named is the mother of all things.
  151.      
  152.      #endif /* TWO */
  153.      Therefore let there always be non-being,
  154.        so we may see their subtlety,
  155.      And let there always be being,
  156.        so we may see their outcome.
  157.      The two are the same,
  158.      But after they are produced,
  159.        they have different names.
  160.      #ifdef TWO
  161.      They both may be called deep and profound.
  162.      Deeper and more profound,
  163.      The door of all subtleties!
  164.      #endif /* TWO */
  165.  
  166. 
  167. File: diff.info,  Node: Comparing Directories,  Next: Adjusting Output,  Prev: Output Formats,  Up: Top
  168.  
  169. Comparing Directories
  170. *********************
  171.  
  172.    You can use `diff' to compare some or all of the files in two
  173. directory trees.  When both file name arguments to `diff' are
  174. directories, it compares each file that is contained in both
  175. directories, examining file names in alphabetical order.  Normally
  176. `diff' is silent about pairs of files that contain no differences, but
  177. if you use the `-s' or `--report-identical-files' option, it reports
  178. pairs of identical files.  Normally `diff' reports subdirectories
  179. common to both directories without comparing subdirectories' files, but
  180. if you use the `-r' or `--recursive' option, it compares every
  181. corresponding pair of files in the directory trees, as many levels deep
  182. as they go.
  183.  
  184.    For file names that are in only one of the directories, `diff'
  185. normally does not show the contents of the file that exists; it reports
  186. only that the file exists in that directory and not in the other.  You
  187. can make `diff' act as though the file existed but was empty in the
  188. other directory, so that it outputs the entire contents of the file that
  189. actually exists.  (It is output as either an insertion or a deletion,
  190. depending on whether it is in the first or the second directory given.)
  191. To do this, use the `-N' or `--new-file' option.
  192.  
  193.    If the older directory contains one or more large files that are not
  194. in the newer directory, you can make the patch smaller by using the
  195. `-P' or `--unidirectional-new-file' option instead of `-N'.  This
  196. option is like `-N' except that it only inserts the contents of files
  197. that appear in the second directory but not the first (that is, files
  198. that were added).  At the top of the patch, write instructions for the
  199. user applying the patch to remove the files that were deleted before
  200. applying the patch.  *Note Making Patches::, for more discussion of
  201. making patches for distribution.
  202.  
  203.    To ignore some files while comparing directories, use the `-x
  204. PATTERN' or `--exclude=PATTERN' option.  This option ignores any files
  205. or subdirectories whose base names match the shell pattern PATTERN.
  206. Unlike in the shell, a period at the start of the base of a file name
  207. matches a wildcard at the start of a pattern.  You should enclose
  208. PATTERN in quotes so that the shell does not expand it.  For example,
  209. the option `-x '*.[ao]'' ignores any file whose name ends with `.a' or
  210. `.o'.
  211.  
  212.    This option accumulates if you specify it more than once.  For
  213. example, using the options `-x 'RCS' -x '*,v'' ignores any file or
  214. subdirectory whose base name is `RCS' or ends with `,v'.
  215.  
  216.    If you need to give this option many times, you can instead put the
  217. patterns in a file, one pattern per line, and use the `-X FILE' or
  218. `--exclude-from=FILE' option.
  219.  
  220.    If you have been comparing two directories and stopped partway
  221. through, later you might want to continue where you left off.  You can
  222. do this by using the `-S FILE' or `--starting-file=FILE' option.  This
  223. compares only the file FILE and all alphabetically later files in the
  224. topmost directory level.
  225.  
  226. 
  227. File: diff.info,  Node: Adjusting Output,  Next: diff Performance,  Prev: Comparing Directories,  Up: Top
  228.  
  229. Making `diff' Output Prettier
  230. *****************************
  231.  
  232.    `diff' provides several ways to adjust the appearance of its output.
  233. These adjustments can be applied to any output format.
  234.  
  235. * Menu:
  236.  
  237. * Tabs::        Preserving the alignment of tabstops.
  238. * Pagination::        Page numbering and timestamping `diff' output.
  239.  
  240. 
  241. File: diff.info,  Node: Tabs,  Next: Pagination,  Up: Adjusting Output
  242.  
  243. Preserving Tabstop Alignment
  244. ============================
  245.  
  246.    The lines of text in some of the `diff' output formats are preceded
  247. by one or two characters that indicate whether the text is inserted,
  248. deleted, or changed.  The addition of those characters can cause tabs to
  249. move to the next tabstop, throwing off the alignment of columns in the
  250. line.  GNU `diff' provides two ways to make tab-aligned columns line up
  251. correctly.
  252.  
  253.    The first way is to have `diff' convert all tabs into the correct
  254. number of spaces before outputting them; select this method with the
  255. `-t' or `--expand-tabs' option.  `diff' assumes that tabstops are set
  256. every 8 columns.  To use this form of output with `patch', you must
  257. give `patch' the `-l' or `--ignore-whitespace' option (*note Changed
  258. Whitespace::., for more information).
  259.  
  260.    The other method for making tabs line up correctly is to add a tab
  261. character instead of a space after the indicator character at the
  262. beginning of the line.  This ensures that all following tab characters
  263. are in the same position relative to tabstops that they were in the
  264. original files, so that the output is aligned correctly.  Its
  265. disadvantage is that it can make long lines too long to fit on one line
  266. of the screen or the paper.  It also does not work with the unified
  267. output format, which does not have a space character after the change
  268. type indicator character.  Select this method with the `-T' or
  269. `--initial-tab' option.
  270.  
  271. 
  272. File: diff.info,  Node: Pagination,  Prev: Tabs,  Up: Adjusting Output
  273.  
  274. Paginating `diff' Output
  275. ========================
  276.  
  277.    It can be convenient to have long output page-numbered and
  278. time-stamped.  The `-l' and `--paginate' options do this by sending the
  279. `diff' output through the `pr' program.  Here is what the page header
  280. might look like for `diff -lc lao tzu':
  281.  
  282.      Mar 11 13:37 1991  diff -lc lao tzu Page 1
  283.  
  284. 
  285. File: diff.info,  Node: diff Performance,  Next: Comparing Three Files,  Prev: Adjusting Output,  Up: Top
  286.  
  287. `diff' Performance Tradeoffs
  288. ****************************
  289.  
  290.    GNU `diff' runs quite efficiently; however, in some circumstances
  291. you can cause it to run faster or produce a more compact set of changes.
  292. There are two ways that you can affect the performance of GNU `diff' by
  293. changing the way it compares files.
  294.  
  295.    Performance has more than one dimension.  These options improve one
  296. aspect of performance at the cost of another, or they improve
  297. performance in some cases while hurting it in others.
  298.  
  299.    The way that GNU `diff' determines which lines have changed always
  300. comes up with a near-minimal set of differences.  Usually it is good
  301. enough for practical purposes.  If the `diff' output is large, you
  302. might want `diff' to use a modified algorithm that sometimes produces a
  303. smaller set of differences.  The `-d' or `--minimal' option does this;
  304. however, it can also cause `diff' to run more slowly than usual, so it
  305. is not the default behavior.
  306.  
  307.    When the files you are comparing are large and have small groups of
  308. changes scattered throughout them, you can use the `-H' or
  309. `--speed-large-files' option to make a different modification to the
  310. algorithm that `diff' uses.  If the input files have a constant small
  311. density of changes, this option speeds up the comparisons without
  312. changing the output.  If not, `diff' might produce a larger set of
  313. differences; however, the output will still be correct.
  314.  
  315.    Normally `diff' discards the prefix and suffix that is common to
  316. both files before it attempts to find a minimal set of differences.
  317. This makes `diff' run faster, but occasionally it may produce
  318. non-minimal output.  The `--horizon-lines=LINES' option prevents `diff'
  319. from discarding the last LINES lines of the prefix and the first LINES
  320. lines of the suffix.  This gives `diff' further opportunities to find a
  321. minimal output.
  322.  
  323. 
  324. File: diff.info,  Node: Comparing Three Files,  Next: diff3 Merging,  Prev: diff Performance,  Up: Top
  325.  
  326. Comparing Three Files
  327. *********************
  328.  
  329.    Use the program `diff3' to compare three files and show any
  330. differences among them.  (`diff3' can also merge files; see *Note diff3
  331. Merging::).
  332.  
  333.    The "normal" `diff3' output format shows each hunk of differences
  334. without surrounding context.  Hunks are labeled depending on whether
  335. they are two-way or three-way, and lines are annotated by their
  336. location in the input files.
  337.  
  338.    *Note Invoking diff3::, for more information on how to run `diff3'.
  339.  
  340. * Menu:
  341.  
  342. * Sample diff3 Input::        Sample `diff3' input for examples.
  343. * Detailed diff3 Normal::    A detailed description of normal output format.
  344. * diff3 Hunks::            The format of normal output format.
  345. * Example diff3 Normal::    Sample output in the normal format.
  346.  
  347. 
  348. File: diff.info,  Node: Sample diff3 Input,  Next: Detailed diff3 Normal,  Up: Comparing Three Files
  349.  
  350. A Third Sample Input File
  351. =========================
  352.  
  353.    Here is a third sample file that will be used in examples to
  354. illustrate the output of `diff3' and how various options can change it.
  355. The first two files are the same that we used for `diff' (*note Sample
  356. diff Input::.).  This is the third sample file, called `tao':
  357.  
  358.      The Way that can be told of is not the eternal Way;
  359.      The name that can be named is not the eternal name.
  360.      The Nameless is the origin of Heaven and Earth;
  361.      The named is the mother of all things.
  362.      
  363.      Therefore let there always be non-being,
  364.        so we may see their subtlety,
  365.      And let there always be being,
  366.        so we may see their result.
  367.      The two are the same,
  368.      But after they are produced,
  369.        they have different names.
  370.      
  371.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  372.  
  373. 
  374. File: diff.info,  Node: Detailed diff3 Normal,  Next: diff3 Hunks,  Prev: Sample diff3 Input,  Up: Comparing Three Files
  375.  
  376. Detailed Description of `diff3' Normal Format
  377. =============================================
  378.  
  379.    Each hunk begins with a line marked `===='.  Three-way hunks have
  380. plain `====' lines, and two-way hunks have `1', `2', or `3' appended to
  381. specify which of the three input files differ in that hunk.  The hunks
  382. contain copies of two or three sets of input lines each preceded by one
  383. or two commands identifying where the lines came from.  Two spaces
  384. precede each copy of an input line to distinguish it from the commands.
  385. Commands take the following forms:
  386.  
  387. `FILE:La'
  388.      This hunk appears after line L of file FILE, and contains no lines
  389.      in that file.  To edit this file to yield the other files, one
  390.      must append hunk lines taken from the other files.  For example,
  391.      `1:11a' means that the hunk follows line 11 in the first file and
  392.      contains no lines from that file.
  393.  
  394. `FILE:Rc'
  395.      This hunk contains the lines in the range R of file FILE.  The
  396.      range R is a comma-separated pair of line numbers, or just one
  397.      number if the range is a singleton.  To edit this file to yield the
  398.      other files, one must change the specified lines to be the lines
  399.      taken from the other files.  For example, `2:11,13c' means that
  400.      the hunk contains lines 11 through 13 from the second file.
  401.  
  402.    If the last line in a set of input lines is incomplete (*note
  403. Incomplete Lines::.), it is distinguished on output from a full line by
  404. a following line that starts with `\'.
  405.  
  406. 
  407. File: diff.info,  Node: diff3 Hunks,  Next: Example diff3 Normal,  Prev: Detailed diff3 Normal,  Up: Comparing Three Files
  408.  
  409. `diff3' Hunks
  410. =============
  411.  
  412.    Groups of lines that differ in two or three of the input files are
  413. called "diff3 hunks", by analogy with `diff' hunks (*note Hunks::.).
  414. If all three input files differ in a `diff3' hunk, the hunk is called a
  415. "three-way hunk"; if just two input files differ, it is a "two-way
  416. hunk".
  417.  
  418.    As with `diff', several solutions are possible.  When comparing the
  419. files `A', `B', and `C', `diff3' normally finds `diff3' hunks by
  420. merging the two-way hunks output by the two commands `diff A B' and
  421. `diff A C'.  This does not necessarily minimize the size of the output,
  422. but exceptions should be rare.
  423.  
  424.    For example, suppose `F' contains the three lines `a', `b', `f', `G'
  425. contains the lines `g', `b', `g', and `H' contains the lines `a', `b',
  426. `h'.  `diff3 F G H' might output the following:
  427.  
  428.      ====2
  429.      1:1c
  430.      3:1c
  431.        a
  432.      2:1c
  433.        g
  434.      ====
  435.      1:3c
  436.        f
  437.      2:3c
  438.        g
  439.      3:3c
  440.        h
  441.  
  442. because it found a two-way hunk containing `a' in the first and third
  443. files and `g' in the second file, then the single line `b' common to
  444. all three files, then a three-way hunk containing the last line of each
  445. file.
  446.  
  447. 
  448. File: diff.info,  Node: Example diff3 Normal,  Prev: diff3 Hunks,  Up: Comparing Three Files
  449.  
  450. An Example of `diff3' Normal Format
  451. ===================================
  452.  
  453.    Here is the output of the command `diff3 lao tzu tao' (*note Sample
  454. diff3 Input::., for the complete contents of the files).  Notice that
  455. it shows only the lines that are different among the three files.
  456.  
  457.      ====2
  458.      1:1,2c
  459.      3:1,2c
  460.        The Way that can be told of is not the eternal Way;
  461.        The name that can be named is not the eternal name.
  462.      2:0a
  463.      ====1
  464.      1:4c
  465.        The Named is the mother of all things.
  466.      2:2,3c
  467.      3:4,5c
  468.        The named is the mother of all things.
  469.      
  470.      ====3
  471.      1:8c
  472.      2:7c
  473.          so we may see their outcome.
  474.      3:9c
  475.          so we may see their result.
  476.      ====
  477.      1:11a
  478.      2:11,13c
  479.        They both may be called deep and profound.
  480.        Deeper and more profound,
  481.        The door of all subtleties!
  482.      3:13,14c
  483.      
  484.          -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  485.  
  486. 
  487. File: diff.info,  Node: diff3 Merging,  Next: Interactive Merging,  Prev: Comparing Three Files,  Up: Top
  488.  
  489. Merging From a Common Ancestor
  490. ******************************
  491.  
  492.    When two people have made changes to copies of the same file,
  493. `diff3' can produce a merged output that contains both sets of changes
  494. together with warnings about conflicts.
  495.  
  496.    One might imagine programs with names like `diff4' and `diff5' to
  497. compare more than three files simultaneously, but in practice the need
  498. rarely arises.  You can use `diff3' to merge three or more sets of
  499. changes to a file by merging two change sets at a time.
  500.  
  501.    `diff3' can incorporate changes from two modified versions into a
  502. common preceding version.  This lets you merge the sets of changes
  503. represented by the two newer files.  Specify the common ancestor version
  504. as the second argument and the two newer versions as the first and third
  505. arguments, like this:
  506.  
  507.      diff3 MINE OLDER YOURS
  508.  
  509. You can remember the order of the arguments by noting that they are in
  510. alphabetical order.
  511.  
  512.    You can think of this as subtracting OLDER from YOURS and adding the
  513. result to MINE, or as merging into MINE the changes that would turn
  514. OLDER into YOURS.  This merging is well-defined as long as MINE and
  515. OLDER match in the neighborhood of each such change.  This fails to be
  516. true when all three input files differ or when only OLDER differs; we
  517. call this a "conflict".  When all three input files differ, we call the
  518. conflict an "overlap".
  519.  
  520.    `diff3' gives you several ways to handle overlaps and conflicts.
  521. You can omit overlaps or conflicts, or select only overlaps, or mark
  522. conflicts with special `<<<<<<<' and `>>>>>>>' lines.
  523.  
  524.    `diff3' can output the merge results as an `ed' script that that can
  525. be applied to the first file to yield the merged output.  However, it
  526. is usually better to have `diff3' generate the merged output directly;
  527. this bypasses some problems with `ed'.
  528.  
  529. * Menu:
  530.  
  531. * Which Changes::        Selecting changes to incorporate.
  532. * Marking Conflicts::        Marking conflicts.
  533. * Bypassing ed::        Generating merged output directly.
  534. * Merging Incomplete Lines::    How `diff3' merges incomplete lines.
  535. * Saving the Changed File::    Emulating System V behavior.
  536.  
  537. 
  538. File: diff.info,  Node: Which Changes,  Next: Marking Conflicts,  Up: diff3 Merging
  539.  
  540. Selecting Which Changes to Incorporate
  541. ======================================
  542.  
  543.    You can select all unmerged changes from OLDER to YOURS for merging
  544. into MINE with the `-e' or `--ed' option.  You can select only the
  545. nonoverlapping unmerged changes with `-3' or `--easy-only', and you can
  546. select only the overlapping changes with `-x' or `--overlap-only'.
  547.  
  548.    The `-e', `-3' and `-x' options select only "unmerged changes", i.e.
  549. changes where MINE and YOURS differ; they ignore changes from OLDER to
  550. YOURS where MINE and YOURS are identical, because they assume that such
  551. changes have already been merged.  If this assumption is not a safe
  552. one, you can use the `-A' or `--show-all' option (*note Marking
  553. Conflicts::.).
  554.  
  555.    Here is the output of the command `diff3' with each of these three
  556. options (*note Sample diff3 Input::., for the complete contents of the
  557. files).  Notice that `-e' outputs the union of the disjoint sets of
  558. changes output by `-3' and `-x'.
  559.  
  560.    Output of `diff3 -e lao tzu tao':
  561.      11a
  562.      
  563.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  564.      .
  565.      8c
  566.        so we may see their result.
  567.      .
  568.  
  569.    Output of `diff3 -3 lao tzu tao':
  570.      8c
  571.        so we may see their result.
  572.      .
  573.  
  574.    Output of `diff3 -x lao tzu tao':
  575.      11a
  576.      
  577.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  578.      .
  579.  
  580. 
  581. File: diff.info,  Node: Marking Conflicts,  Next: Bypassing ed,  Prev: Which Changes,  Up: diff3 Merging
  582.  
  583. Marking Conflicts
  584. =================
  585.  
  586.    `diff3' can mark conflicts in the merged output by bracketing them
  587. with special marker lines.  A conflict that comes from two files A and
  588. B is marked as follows:
  589.  
  590.      <<<<<<< A
  591.      lines from A
  592.      =======
  593.      lines from B
  594.      >>>>>>> B
  595.  
  596.    A conflict that comes from three files A, B and C is marked as
  597. follows:
  598.  
  599.      <<<<<<< A
  600.      lines from A
  601.      ||||||| B
  602.      lines from B
  603.      =======
  604.      lines from C
  605.      >>>>>>> C
  606.  
  607.    The `-A' or `--show-all' option acts like the `-e' option, except
  608. that it brackets conflicts, and it outputs all changes from OLDER to
  609. YOURS, not just the unmerged changes.  Thus, given the sample input
  610. files (*note Sample diff3 Input::.), `diff3 -A lao tzu tao' puts
  611. brackets around the conflict where only `tzu' differs:
  612.  
  613.      <<<<<<< tzu
  614.      =======
  615.      The Way that can be told of is not the eternal Way;
  616.      The name that can be named is not the eternal name.
  617.      >>>>>>> tao
  618.  
  619.    And it outputs the three-way conflict as follows:
  620.  
  621.      <<<<<<< lao
  622.      ||||||| tzu
  623.      They both may be called deep and profound.
  624.      Deeper and more profound,
  625.      The door of all subtleties!
  626.      =======
  627.      
  628.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  629.      >>>>>>> tao
  630.  
  631.    The `-E' or `--show-overlap' option outputs less information than
  632. the `-A' or `--show-all' option, because it outputs only unmerged
  633. changes, and it never outputs the contents of the second file.  Thus
  634. the `-E' option acts like the `-e' option, except that it brackets the
  635. first and third files from three-way overlapping changes.  Similarly,
  636. `-X' acts like `-x', except it brackets all its (necessarily
  637. overlapping) changes.  For example, for the three-way overlapping
  638. change above, the `-E' and `-X' options output the following:
  639.  
  640.      <<<<<<< lao
  641.      =======
  642.      
  643.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  644.      >>>>>>> tao
  645.  
  646.    If you are comparing files that have meaningless or uninformative
  647. names, you can use the `-L LABEL' or `--label=LABEL' option to show
  648. alternate names in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets.
  649. This option can be given up to three times, once for each input file.
  650. Thus `diff3 -A -L X -L Y -L Z A B C' acts like `diff3 -A A B C', except
  651. that the output looks like it came from files named `X', `Y' and `Z'
  652. rather than from files named `A', `B' and `C'.
  653.  
  654. 
  655. File: diff.info,  Node: Bypassing ed,  Next: Merging Incomplete Lines,  Prev: Marking Conflicts,  Up: diff3 Merging
  656.  
  657. Generating the Merged Output Directly
  658. =====================================
  659.  
  660.    With the `-m' or `--merge' option, `diff3' outputs the merged file
  661. directly.  This is more efficient than using `ed' to generate it, and
  662. works even with non-text files that `ed' would reject.  If you specify
  663. `-m' without an `ed' script option, `-A' (`--show-all') is assumed.
  664.  
  665.    For example, the command `diff3 -m lao tzu tao' (*note Sample diff3
  666. Input::. for a copy of the input files) would output the following:
  667.  
  668.      <<<<<<< tzu
  669.      =======
  670.      The Way that can be told of is not the eternal Way;
  671.      The name that can be named is not the eternal name.
  672.      >>>>>>> tao
  673.      The Nameless is the origin of Heaven and Earth;
  674.      The Named is the mother of all things.
  675.      Therefore let there always be non-being,
  676.        so we may see their subtlety,
  677.      And let there always be being,
  678.        so we may see their result.
  679.      The two are the same,
  680.      But after they are produced,
  681.        they have different names.
  682.      <<<<<<< lao
  683.      ||||||| tzu
  684.      They both may be called deep and profound.
  685.      Deeper and more profound,
  686.      The door of all subtleties!
  687.      =======
  688.      
  689.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  690.      >>>>>>> tao
  691.  
  692. 
  693. File: diff.info,  Node: Merging Incomplete Lines,  Next: Saving the Changed File,  Prev: Bypassing ed,  Up: diff3 Merging
  694.  
  695. How `diff3' Merges Incomplete Lines
  696. ===================================
  697.  
  698.    With `-m', incomplete lines (*note Incomplete Lines::.) are simply
  699. copied to the output as they are found; if the merged output ends in an
  700. conflict and one of the input files ends in an incomplete line,
  701. succeeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere
  702. other than the start of a line because they are appended to the
  703. incomplete line.
  704.  
  705.    Without `-m', if an `ed' script option is specified and an
  706. incomplete line is found, `diff3' generates a warning and acts as if a
  707. newline had been present.
  708.  
  709. 
  710. File: diff.info,  Node: Saving the Changed File,  Prev: Merging Incomplete Lines,  Up: diff3 Merging
  711.  
  712. Saving the Changed File
  713. =======================
  714.  
  715.    Traditional Unix `diff3' generates an `ed' script without the
  716. trailing `w' and and `q' commands that save the changes.  System V
  717. `diff3' generates these extra commands.  GNU `diff3' normally behaves
  718. like traditional Unix `diff3', but with the `-i' option it behaves like
  719. System V `diff3' and appends the `w' and `q' commands.
  720.  
  721.    The `-i' option requires one of the `ed' script options `-AeExX3',
  722. and is incompatible with the merged output option `-m'.
  723.  
  724. 
  725. File: diff.info,  Node: Interactive Merging,  Next: Merging with patch,  Prev: diff3 Merging,  Up: Top
  726.  
  727. Interactive Merging with `sdiff'
  728. ********************************
  729.  
  730.    With `sdiff', you can merge two files interactively based on a
  731. side-by-side `-y' format comparison (*note Side by Side::.).  Use `-o
  732. FILE' or `--output=FILE' to specify where to put the merged text.
  733. *Note Invoking sdiff::, for more details on the options to `sdiff'.
  734.  
  735.    Another way to merge files interactively is to use the Emacs Lisp
  736. package `emerge'.  *Note emerge: (emacs)emerge, for more information.
  737.  
  738. * Menu:
  739.  
  740. * sdiff Option Summary::Summary of `sdiff' options.
  741. * Merge Commands::    Merging two files interactively.
  742.  
  743. 
  744. File: diff.info,  Node: sdiff Option Summary,  Next: Merge Commands,  Up: Interactive Merging
  745.  
  746. Specifying `diff' Options to `sdiff'
  747. ====================================
  748.  
  749.    The following `sdiff' options have the same meaning as for `diff'.
  750. *Note diff Options::, for the use of these options.
  751.  
  752.      -a -b -d -i -t -v
  753.      -B -H -I REGEXP
  754.      
  755.      --ignore-blank-lines  --ignore-case
  756.      --ignore-matching-lines=REGEXP  --ignore-space-change
  757.      --left-column  --minimal  --speed-large-files
  758.      --suppress-common-lines  --expand-tabs
  759.      --text  --version  --width=COLUMNS
  760.  
  761.    For historical reasons, `sdiff' has alternate names for some
  762. options.  The `-l' option is equivalent to the `--left-column' option,
  763. and similarly `-s' is equivalent to `--suppress-common-lines'.  The
  764. meaning of the `sdiff' `-w' and `-W' options is interchanged from that
  765. of `diff': with `sdiff', `-w COLUMNS' is equivalent to
  766. `--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'.
  767. `sdiff' without the `-o' option is equivalent to `diff' with the `-y'
  768. or `--side-by-side' option (*note Side by Side::.).
  769.  
  770. 
  771. File: diff.info,  Node: Merge Commands,  Prev: sdiff Option Summary,  Up: Interactive Merging
  772.  
  773. Merge Commands
  774. ==============
  775.  
  776.    Groups of common lines, with a blank gutter, are copied from the
  777. first file to the output.  After each group of differing lines, `sdiff'
  778. prompts with `%' and pauses, waiting for one of the following commands.
  779. Follow each command with RET.
  780.  
  781. `e'
  782.      Discard both versions.  Invoke a text editor on an empty temporary
  783.      file, then copy the resulting file to the output.
  784.  
  785. `eb'
  786.      Concatenate the two versions, edit the result in a temporary file,
  787.      then copy the edited result to the output.
  788.  
  789. `el'
  790.      Edit a copy of the left version, then copy the result to the
  791.      output.
  792.  
  793. `er'
  794.      Edit a copy of the right version, then copy the result to the
  795.      output.
  796.  
  797. `l'
  798.      Copy the left version to the output.
  799.  
  800. `q'
  801.      Quit.
  802.  
  803. `r'
  804.      Copy the right version to the output.
  805.  
  806. `s'
  807.      Silently copy common lines.
  808.  
  809. `v'
  810.      Verbosely copy common lines.  This is the default.
  811.  
  812.    The text editor invoked is specified by the `EDITOR' environment
  813. variable if it is set.  The default is system-dependent.
  814.  
  815. 
  816. File: diff.info,  Node: Merging with patch,  Next: Making Patches,  Prev: Interactive Merging,  Up: Top
  817.  
  818. Merging with `patch'
  819. ********************
  820.  
  821.    `patch' takes comparison output produced by `diff' and applies the
  822. differences to a copy of the original file, producing a patched
  823. version.  With `patch', you can distribute just the changes to a set of
  824. files instead of distributing the entire file set; your correspondents
  825. can apply `patch' to update their copy of the files with your changes.
  826. `patch' automatically determines the diff format, skips any leading or
  827. trailing headers, and uses the headers to determine which file to
  828. patch.  This lets your correspondents feed an article or message
  829. containing a difference listing directly to `patch'.
  830.  
  831.    `patch' detects and warns about common problems like forward
  832. patches.  It saves the original version of the files it patches, and
  833. saves any patches that it could not apply.  It can also maintain a
  834. `patchlevel.h' file to ensures that your correspondents apply diffs in
  835. the proper order.
  836.  
  837.    `patch' accepts a series of diffs in its standard input, usually
  838. separated by headers that specify which file to patch.  It applies
  839. `diff' hunks (*note Hunks::.) one by one.  If a hunk does not exactly
  840. match the original file, `patch' uses heuristics to try to patch the
  841. file as well as it can.  If no approximate match can be found, `patch'
  842. rejects the hunk and skips to the next hunk.  `patch' normally replaces
  843. each file F with its new version, saving the original file in `F.orig',
  844. and putting reject hunks (if any) into `F.rej'.
  845.  
  846.    *Note Invoking patch::, for detailed information on the options to
  847. `patch'.  *Note Backups::, for more information on how `patch' names
  848. backup files.  *Note Rejects::, for more information on where `patch'
  849. puts reject hunks.
  850.  
  851. * Menu:
  852.  
  853. * patch Input::        Selecting the type of `patch' input.
  854. * Imperfect::        Dealing with imperfect patches.
  855. * Empty Files::        Removing empty files after patching.
  856. * Multiple Patches::    Handling multiple patches in a file specially.
  857. * patch Messages::    Messages and questions `patch' can produce.
  858.  
  859. 
  860. File: diff.info,  Node: patch Input,  Next: Imperfect,  Up: Merging with patch
  861.  
  862. Selecting the `patch' Input Format
  863. ==================================
  864.  
  865.    `patch' normally determines which `diff' format the patch file uses
  866. by examining its contents.  For patch files that contain particularly
  867. confusing leading text, you might need to use one of the following
  868. options to force `patch' to interpret the patch file as a certain
  869. format of diff.  The output formats listed here are the only ones that
  870. `patch' can understand.
  871.  
  872. `-c'
  873. `--context'
  874.      context diff.
  875.  
  876. `-e'
  877. `--ed'
  878.      `ed' script.
  879.  
  880. `-n'
  881. `--normal'
  882.      normal diff.
  883.  
  884. `-u'
  885. `--unified'
  886.      unified diff.
  887.  
  888. 
  889. File: diff.info,  Node: Imperfect,  Next: Empty Files,  Prev: patch Input,  Up: Merging with patch
  890.  
  891. Applying Imperfect Patches
  892. ==========================
  893.  
  894.    `patch' tries to skip any leading text in the patch file, apply the
  895. diff, and then skip any trailing text.  Thus you can feed a news article
  896. or mail message directly to `patch', and it should work.  If the entire
  897. diff is indented by a constant amount of whitespace, `patch'
  898. automatically ignores the indentation.
  899.  
  900.    However, certain other types of imperfect input require user
  901. intervention.
  902.  
  903. * Menu:
  904.  
  905. * Changed Whitespace::    When tabs and spaces don't match exactly.
  906. * Reversed Patches::    Applying reversed patches correctly.
  907. * Inexact::        Helping `patch' find close matches.
  908.  
  909. 
  910. File: diff.info,  Node: Changed Whitespace,  Next: Reversed Patches,  Up: Imperfect
  911.  
  912. Applying Patches with Changed Whitespace
  913. ----------------------------------------
  914.  
  915.    Sometimes mailers, editors, or other programs change spaces into
  916. tabs, or vice versa.  If this happens to a patch file or an input file,
  917. the files might look the same, but `patch' will not be able to match
  918. them properly.  If this problem occurs, use the `-l' or
  919. `--ignore-whitespace' option, which makes `patch' compare whitespace
  920. loosely so that any sequence of whitespace in the patch file matches
  921. any sequence of whitespace in the input files.  Non-whitespace
  922. characters must still match exactly.  Each line of the context must
  923. still match a line in the input file.
  924.  
  925. 
  926. File: diff.info,  Node: Reversed Patches,  Next: Inexact,  Prev: Changed Whitespace,  Up: Imperfect
  927.  
  928. Applying Reversed Patches
  929. -------------------------
  930.  
  931.    Sometimes people run `diff' with the new file first instead of
  932. second.  This creates a diff that is "reversed".  To apply such
  933. patches, give `patch' the `-R' or `--reverse' option.  `patch' then
  934. attempts to swap each hunk around before applying it.  Rejects come out
  935. in the swapped format.  The `-R' option does not work with `ed' scripts
  936. because there is too little information in them to reconstruct the
  937. reverse operation.
  938.  
  939.    Often `patch' can guess that the patch is reversed.  If the first
  940. hunk of a patch fails, `patch' reverses the hunk to see if it can apply
  941. it that way.  If it can, `patch' asks you if you want to have the `-R'
  942. option set; if it can't, `patch' continues to apply the patch normally.
  943. This method cannot detect a reversed patch if it is a normal diff and
  944. the first command is an append (which should have been a delete) since
  945. appends always succeed, because a null context matches anywhere.  But
  946. most patches add or change lines rather than delete them, so most
  947. reversed normal diffs begin with a delete, which fails, and `patch'
  948. notices.
  949.  
  950.    If you apply a patch that you have already applied, `patch' thinks
  951. it is a reversed patch and offers to un-apply the patch.  This could be
  952. construed as a feature.  If you did this inadvertently and you don't
  953. want to un-apply the patch, just answer `n' to this offer and to the
  954. subsequent "apply anyway" question--or type `C-c' to kill the `patch'
  955. process.
  956.  
  957. 
  958. File: diff.info,  Node: Inexact,  Prev: Reversed Patches,  Up: Imperfect
  959.  
  960. Helping `patch' Find Inexact Matches
  961. ------------------------------------
  962.  
  963.    For context diffs, and to a lesser extent normal diffs, `patch' can
  964. detect when the line numbers mentioned in the patch are incorrect, and
  965. it attempts to find the correct place to apply each hunk of the patch.
  966. As a first guess, it takes the line number mentioned in the hunk, plus
  967. or minus any offset used in applying the previous hunk.  If that is not
  968. the correct place, `patch' scans both forward and backward for a set of
  969. lines matching the context given in the hunk.
  970.  
  971.    First `patch' looks for a place where all lines of the context
  972. match.  If it cannot find such a place, and it is reading a context or
  973. unified diff, and the maximum fuzz factor is set to 1 or more, then
  974. `patch' makes another scan, ignoring the first and last line of
  975. context.  If that fails, and the maximum fuzz factor is set to 2 or
  976. more, it makes another scan, ignoring the first two and last two lines
  977. of context are ignored.  It continues similarly if the maximum fuzz
  978. factor is larger.
  979.  
  980.    The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor
  981. to LINES.  This option only applies to context and unified diffs; it
  982. ignores up to LINES lines while looking for the place to install a
  983. hunk.  Note that a larger fuzz factor increases the odds of making a
  984. faulty patch.  The default fuzz factor is 2; it may not be set to more
  985. than the number of lines of context in the diff, ordinarily 3.
  986.  
  987.    If `patch' cannot find a place to install a hunk of the patch, it
  988. writes the hunk out to a reject file (*note Rejects::., for information
  989. on how reject files are named).  It writes out rejected hunks in context
  990. format no matter what form the input patch is in.  If the input is a
  991. normal or `ed' diff, many of the contexts are simply null.  The line
  992. numbers on the hunks in the reject file may be different from those in
  993. the patch file: they show the approximate location where `patch' thinks
  994. the failed hunks belong in the new file rather than in the old one.
  995.  
  996.    As it completes each hunk, `patch' tells you whether the hunk
  997. succeeded or failed, and if it failed, on which line (in the new file)
  998. `patch' thinks the hunk should go.  If this is different from the line
  999. number specified in the diff, it tells you the offset.  A single large
  1000. offset *may* indicate that `patch' installed a hunk in the wrong place.
  1001. `patch' also tells you if it used a fuzz factor to make the match, in
  1002. which case you should also be slightly suspicious.
  1003.  
  1004.    `patch' cannot tell if the line numbers are off in an `ed' script,
  1005. and can only detect wrong line numbers in a normal diff when it finds a
  1006. change or delete command.  It may have the same problem with a context
  1007. diff using a fuzz factor equal to or greater than the number of lines
  1008. of context shown in the diff (typically 3).  In these cases, you should
  1009. probably look at a context diff between your original and patched input
  1010. files to see if the changes make sense.  Compiling without errors is a
  1011. pretty good indication that the patch worked, but not a guarantee.
  1012.  
  1013.    `patch' usually produces the correct results, even when it must make
  1014. many guesses.  However, the results are guaranteed only when the patch
  1015. is applied to an exact copy of the file that the patch was generated
  1016. from.
  1017.  
  1018. 
  1019. File: diff.info,  Node: Empty Files,  Next: Multiple Patches,  Prev: Imperfect,  Up: Merging with patch
  1020.  
  1021. Removing Empty Files
  1022. ====================
  1023.  
  1024.    Sometimes when comparing two directories, the first directory
  1025. contains a file that the second directory does not.  If you give `diff'
  1026. the `-N' or `--new-file' option, it outputs a diff that deletes the
  1027. contents of this file.  By default, `patch' leaves an empty file after
  1028. applying such a diff.  The `-E' or `--remove-empty-files' option to
  1029. `patch' deletes output files that are empty after applying the diff.
  1030.  
  1031. 
  1032. File: diff.info,  Node: Multiple Patches,  Next: patch Messages,  Prev: Empty Files,  Up: Merging with patch
  1033.  
  1034. Multiple Patches in a File
  1035. ==========================
  1036.  
  1037.    If the patch file contains more than one patch, `patch' tries to
  1038. apply each of them as if they came from separate patch files.  This
  1039. means that it determines the name of the file to patch for each patch,
  1040. and that it examines the leading text before each patch for file names
  1041. and prerequisite revision level (*note Making Patches::., for more on
  1042. that topic).
  1043.  
  1044.    For the second and subsequent patches in the patch file, you can give
  1045. options and another original file name by separating their argument
  1046. lists with a `+'.  However, the argument list for a second or
  1047. subsequent patch may not specify a new patch file, since that does not
  1048. make sense.
  1049.  
  1050.    For example, to tell `patch' to strip the first three slashes from
  1051. the name of the first patch in the patch file and none from subsequent
  1052. patches, and to use `code.c' as the first input file, you can use:
  1053.  
  1054.      patch -p3 code.c + -p0 < patchfile
  1055.  
  1056.    The `-S' or `--skip' option ignores the current patch from the patch
  1057. file, but continue looking for the next patch in the file.  Thus, to
  1058. ignore the first and third patches in the patch file, you can use:
  1059.  
  1060.      patch -S + + -S + < patch file
  1061.  
  1062. 
  1063. File: diff.info,  Node: patch Messages,  Prev: Multiple Patches,  Up: Merging with patch
  1064.  
  1065. Messages and Questions from `patch'
  1066. ===================================
  1067.  
  1068.    `patch' can produce a variety of messages, especially if it has
  1069. trouble decoding its input.  In a few situations where it's not sure how
  1070. to proceed, `patch' normally prompts you for more information from the
  1071. keyboard.  There are options to suppress printing non-fatal messages
  1072. and stopping for keyboard input.
  1073.  
  1074.    The message `Hmm...' indicates that `patch' is reading text in the
  1075. patch file, attempting to determine whether there is a patch in that
  1076. text, and if so, what kind of patch it is.
  1077.  
  1078.    You can inhibit all terminal output from `patch', unless an error
  1079. occurs, by using the `-s', `--quiet', or `--silent' option.
  1080.  
  1081.    There are two ways you can prevent `patch' from asking you any
  1082. questions.  The `-f' or `--force' option assumes that you know what you
  1083. are doing.  It assumes the following:
  1084.  
  1085.    * skip patches for which it can't find a file to patch;
  1086.  
  1087.    * patch files even though they have the wrong version for the
  1088.      `Prereq:' line in the patch;
  1089.  
  1090.    * assume that patches are not reversed even if they look like they
  1091.      are.
  1092.  
  1093.    The `-t' or `--batch' option is similar to `-f', in that it
  1094. suppresses questions, but it makes somewhat different assumptions:
  1095.  
  1096.    * skip patches for which it can't find a file to patch (the same as
  1097.      `-f');
  1098.  
  1099.    * skip patches for which the file has the wrong version for the
  1100.      `Prereq:' line in the patch;
  1101.  
  1102.    * assume that patches are reversed if they look like they are.
  1103.  
  1104.    `patch' exits with a non-zero status if it creates any reject files.
  1105. When applying a set of patches in a loop, you should check the exit
  1106. status, so you don't apply a later patch to a partially patched file.
  1107.  
  1108. 
  1109. File: diff.info,  Node: Making Patches,  Next: Invoking cmp,  Prev: Merging with patch,  Up: Top
  1110.  
  1111. Tips for Making Patch Distributions
  1112. ***********************************
  1113.  
  1114.    Here are some things you should keep in mind if you are going to
  1115. distribute patches for updating a software package.
  1116.  
  1117.    Make sure you have specified the file names correctly, either in a
  1118. context diff header or with an `Index:' line.  If you are patching
  1119. files in a subdirectory, be sure to tell the patch user to specify a
  1120. `-p' or `--strip' option as needed.  Take care to not send out reversed
  1121. patches, since these make people wonder whether they have already
  1122. applied the patch.
  1123.  
  1124.    To save people from partially applying a patch before other patches
  1125. that should have gone before it, you can make the first patch in the
  1126. patch file update a file with a name like `patchlevel.h' or
  1127. `version.c', which contains a patch level or version number.  If the
  1128. input file contains the wrong version number, `patch' will complain
  1129. immediately.
  1130.  
  1131.    An even clearer way to prevent this problem is to put a `Prereq:'
  1132. line before the patch.  If the leading text in the patch file contains a
  1133. line that starts with `Prereq:', `patch' takes the next word from that
  1134. line (normally a version number) and checks whether the next input file
  1135. contains that word, preceded and followed by either whitespace or a
  1136. newline.  If not, `patch' prompts you for confirmation before
  1137. proceeding.  This makes it difficult to accidentally apply patches in
  1138. the wrong order.
  1139.  
  1140.    Since `patch' does not handle incomplete lines properly, make sure
  1141. that all the source files in your program end with a newline whenever
  1142. you release a version.
  1143.  
  1144.    To create a patch that changes an older version of a package into a
  1145. newer version, first make a copy of the older version in a scratch
  1146. directory.  Typically you do that by unpacking a `tar' or `shar'
  1147. archive of the older version.
  1148.  
  1149.    You might be able to reduce the size of the patch by renaming or
  1150. removing some files before making the patch.  If the older version of
  1151. the package contains any files that the newer version does not, or if
  1152. any files have been renamed between the two versions, make a list of
  1153. `rm' and `mv' commands for the user to execute in the old version
  1154. directory before applying the patch.  Then run those commands yourself
  1155. in the scratch directory.
  1156.  
  1157.    If there are any files that you don't need to include in the patch
  1158. because they can easily be rebuilt from other files (for example,
  1159. `TAGS' and output from `yacc' and `makeinfo'), replace the versions in
  1160. the scratch directory with the newer versions, using `rm' and `ln' or
  1161. `cp'.
  1162.  
  1163.    Now you can create the patch.  The de-facto standard `diff' format
  1164. for patch distributions is context format with two lines of context,
  1165. produced by giving `diff' the `-C 2' option.  Do not use less than two
  1166. lines of context, because `patch' typically needs at least two lines
  1167. for proper operation.  Give `diff' the `-P' option in case the newer
  1168. version of the package contains any files that the older one does not.
  1169. Make sure to specify the scratch directory first and the newer
  1170. directory second.
  1171.  
  1172.    Add to the top of the patch a note telling the user any `rm' and
  1173. `mv' commands to run before applying the patch.  Then you can remove
  1174. the scratch directory.
  1175.  
  1176. 
  1177. File: diff.info,  Node: Invoking cmp,  Next: Invoking diff,  Prev: Making Patches,  Up: Top
  1178.  
  1179. Invoking `cmp'
  1180. **************
  1181.  
  1182.    The `cmp' command compares two files, and if they differ, tells the
  1183. first byte and line number where they differ.  Its arguments are as
  1184. follows:
  1185.  
  1186.      cmp OPTIONS... FROM-FILE [TO-FILE]
  1187.  
  1188.    The file name `-' is always the standard input.  `cmp' also uses the
  1189. standard input if one file name is omitted.
  1190.  
  1191.    An exit status of 0 means no differences were found, 1 means some
  1192. differences were found, and 2 means trouble.
  1193.  
  1194. * Menu:
  1195.  
  1196. * cmp Options::        Summary of options to `cmp'.
  1197.  
  1198. 
  1199. File: diff.info,  Node: cmp Options,  Up: Invoking cmp
  1200.  
  1201. Options to `cmp'
  1202. ================
  1203.  
  1204.    Below is a summary of all of the options that GNU `cmp' accepts.
  1205. Most options have two equivalent names, one of which is a single letter
  1206. preceded by `-', and the other of which is a long name preceded by
  1207. `--'.  Multiple single letter options (unless they take an argument)
  1208. can be combined into a single command line word: `-cl' is equivalent to
  1209. `-c -l'.
  1210.  
  1211. `-c'
  1212.      Print the differing characters.  Display control characters as a
  1213.      `^' followed by a letter of the alphabet and precede characters
  1214.      that have the high bit set with `M-' (which stands for "meta").
  1215.  
  1216. `-l'
  1217.      Print the (decimal) offsets and (octal) values of all differing
  1218.      bytes.
  1219.  
  1220. `--print-chars'
  1221.      Print the differing characters.  Display control characters as a
  1222.      `^' followed by a letter of the alphabet and precede characters
  1223.      that have the high bit set with `M-' (which stands for "meta").
  1224.  
  1225. `--quiet'
  1226. `-s'
  1227. `--silent'
  1228.      Do not print anything; only return an exit status indicating
  1229.      whether the files differ.
  1230.  
  1231. `--verbose'
  1232.      Print the (decimal) offsets and (octal) values of all differing
  1233.      bytes.
  1234.  
  1235. 
  1236. File: diff.info,  Node: Invoking diff,  Next: Invoking diff3,  Prev: Invoking cmp,  Up: Top
  1237.  
  1238. Invoking `diff'
  1239. ***************
  1240.  
  1241.    The format for running the `diff' command is:
  1242.  
  1243.      diff OPTIONS... FROM-FILE TO-FILE
  1244.  
  1245.    In the simplest case, `diff' compares the contents of the two files
  1246. FROM-FILE and TO-FILE.  A file name of `-' stands for text read from
  1247. the standard input.  As a special case, `diff - -' compares a copy of
  1248. standard input to itself.
  1249.  
  1250.    If FROM-FILE is a directory and TO-FILE is not, `diff' compares the
  1251. file in FROM-FILE whose file name is that of TO-FILE, and vice versa.
  1252. The non-directory file must not be `-'.
  1253.  
  1254.    If both FROM-FILE and TO-FILE are directories, `diff' compares
  1255. corresponding files in both directories, in alphabetical order; this
  1256. comparison is not recursive unless the `-r' or `--recursive' option is
  1257. given.  `diff' never compares the actual contents of a directory as if
  1258. it were a file.  The file that is fully specified may not be standard
  1259. input, because standard input is nameless and the notion of "file with
  1260. the same name" does not apply.
  1261.  
  1262.    `diff' options begin with `-', so normally FROM-FILE and TO-FILE may
  1263. not begin with `-'.  However, `--' as an argument by itself treats the
  1264. remaining arguments as file names even if they begin with `-'.
  1265.  
  1266.    An exit status of 0 means no differences were found, 1 means some
  1267. differences were found, and 2 means trouble.
  1268.  
  1269. * Menu:
  1270.  
  1271. * diff Options::    Summary of options to `diff'.
  1272.  
  1273.