home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / info / diff.info-2 < prev    next >
Encoding:
GNU Info File  |  1995-07-29  |  48.5 KB  |  1,263 lines

  1. This is Info file diff.info, produced by Makeinfo-1.55 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. 
  316. File: diff.info,  Node: Comparing Three Files,  Next: diff3 Merging,  Prev: diff Performance,  Up: Top
  317.  
  318. Comparing Three Files
  319. *********************
  320.  
  321.    Use the program `diff3' to compare three files and show any
  322. differences among them.  (`diff3' can also merge files; see *Note diff3
  323. Merging::).
  324.  
  325.    The "normal" `diff3' output format shows each hunk of differences
  326. without surrounding context.  Hunks are labeled depending on whether
  327. they are two-way or three-way, and lines are annotated by their
  328. location in the input files.
  329.  
  330.    *Note Invoking diff3::, for more information on how to run `diff3'.
  331.  
  332. * Menu:
  333.  
  334. * Sample diff3 Input::        Sample `diff3' input for examples.
  335. * Detailed diff3 Normal::    A detailed description of normal output format.
  336. * diff3 Hunks::            The format of normal output format.
  337. * Example diff3 Normal::    Sample output in the normal format.
  338.  
  339. 
  340. File: diff.info,  Node: Sample diff3 Input,  Next: Detailed diff3 Normal,  Up: Comparing Three Files
  341.  
  342. A Third Sample Input File
  343. =========================
  344.  
  345.    Here is a third sample file that will be used in examples to
  346. illustrate the output of `diff3' and how various options can change it.
  347. The first two files are the same that we used for `diff' (*note Sample
  348. diff Input::.).  This is the third sample file, called `tao':
  349.  
  350.      The Way that can be told of is not the eternal Way;
  351.      The name that can be named is not the eternal name.
  352.      The Nameless is the origin of Heaven and Earth;
  353.      The named is the mother of all things.
  354.      
  355.      Therefore let there always be non-being,
  356.        so we may see their subtlety,
  357.      And let there always be being,
  358.        so we may see their result.
  359.      The two are the same,
  360.      But after they are produced,
  361.        they have different names.
  362.      
  363.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  364.  
  365. 
  366. File: diff.info,  Node: Detailed diff3 Normal,  Next: diff3 Hunks,  Prev: Sample diff3 Input,  Up: Comparing Three Files
  367.  
  368. Detailed Description of `diff3' Normal Format
  369. =============================================
  370.  
  371.    Each hunk begins with a line marked `===='.  Three-way hunks have
  372. plain `====' lines, and two-way hunks have `1', `2', or `3' appended to
  373. specify which of the three input files differ in that hunk.  The hunks
  374. contain copies of two or three sets of input lines each preceded by one
  375. or two commands identifying where the lines came from.  Two spaces
  376. precede each copy of an input line to distinguish it from the commands.
  377. Commands take the following forms:
  378.  
  379. `FILE:La'
  380.      This hunk appears after line L of file FILE, and contains no lines
  381.      in that file.  To edit this file to yield the other files, one
  382.      must append hunk lines taken from the other files.  For example,
  383.      `1:11a' means that the hunk follows line 11 in the first file and
  384.      contains no lines from that file.
  385.  
  386. `FILE:Rc'
  387.      This hunk contains the lines in the range R of file FILE.  The
  388.      range R is a comma-separated pair of line numbers, or just one
  389.      number if the range is a singleton.  To edit this file to yield the
  390.      other files, one must change the specified lines to be the lines
  391.      taken from the other files.  For example, `2:11,13c' means that
  392.      the hunk contains lines 11 through 13 from the second file.
  393.  
  394.    If the last line in a set of input lines is incomplete (*note
  395. Incomplete Lines::.), it is distinguished on output from a full line by
  396. a following line that starts with `\'.
  397.  
  398. 
  399. File: diff.info,  Node: diff3 Hunks,  Next: Example diff3 Normal,  Prev: Detailed diff3 Normal,  Up: Comparing Three Files
  400.  
  401. `diff3' Hunks
  402. =============
  403.  
  404.    Groups of lines that differ in two or three of the input files are
  405. called "diff3 hunks", by analogy with `diff' hunks (*note Hunks::.).
  406. If all three input files differ in a `diff3' hunk, the hunk is called a
  407. "three-way hunk"; if just two input files differ, it is a "two-way
  408. hunk".
  409.  
  410.    As with `diff', several solutions are possible.  When comparing the
  411. files `A', `B', and `C', `diff3' normally finds `diff3' hunks by
  412. merging the two-way hunks output by the two commands `diff A B' and
  413. `diff A C'.  This does not necessarily minimize the size of the output,
  414. but exceptions should be rare.
  415.  
  416.    For example, suppose `F' contains the three lines `a', `b', `f', `G'
  417. contains the lines `g', `b', `g', and `H' contains the lines `a', `b',
  418. `h'.  `diff3 F G H' might output the following:
  419.  
  420.      ====2
  421.      1:1c
  422.      3:1c
  423.        a
  424.      2:1c
  425.        g
  426.      ====
  427.      1:3c
  428.        f
  429.      2:3c
  430.        g
  431.      3:3c
  432.        h
  433.  
  434. because it found a two-way hunk containing `a' in the first and third
  435. files and `g' in the second file, then the single line `b' common to
  436. all three files, then a three-way hunk containing the last line of each
  437. file.
  438.  
  439. 
  440. File: diff.info,  Node: Example diff3 Normal,  Prev: diff3 Hunks,  Up: Comparing Three Files
  441.  
  442. An Example of `diff3' Normal Format
  443. ===================================
  444.  
  445.    Here is the output of the command `diff3 lao tzu tao' (*note Sample
  446. diff3 Input::., for the complete contents of the files).  Notice that
  447. it shows only the lines that are different among the three files.
  448.  
  449.      ====2
  450.      1:1,2c
  451.      3:1,2c
  452.        The Way that can be told of is not the eternal Way;
  453.        The name that can be named is not the eternal name.
  454.      2:0a
  455.      ====1
  456.      1:4c
  457.        The Named is the mother of all things.
  458.      2:2,3c
  459.      3:4,5c
  460.        The named is the mother of all things.
  461.      
  462.      ====3
  463.      1:8c
  464.      2:7c
  465.          so we may see their outcome.
  466.      3:9c
  467.          so we may see their result.
  468.      ====
  469.      1:11a
  470.      2:11,13c
  471.        They both may be called deep and profound.
  472.        Deeper and more profound,
  473.        The door of all subtleties!
  474.      3:13,14c
  475.      
  476.          -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  477.  
  478. 
  479. File: diff.info,  Node: diff3 Merging,  Next: Interactive Merging,  Prev: Comparing Three Files,  Up: Top
  480.  
  481. Merging From a Common Ancestor
  482. ******************************
  483.  
  484.    When two people have made changes to copies of the same file,
  485. `diff3' can produce a merged output that contains both sets of changes
  486. together with warnings about conflicts.
  487.  
  488.    One might imagine programs with names like `diff4' and `diff5' to
  489. compare more than three files simultaneously, but in practice the need
  490. rarely arises.  You can use `diff3' to merge three or more sets of
  491. changes to a file by merging two change sets at a time.
  492.  
  493.    `diff3' can incorporate changes from two modified versions into a
  494. common preceding version.  This lets you merge the sets of changes
  495. represented by the two newer files.  Specify the common ancestor version
  496. as the second argument and the two newer versions as the first and third
  497. arguments, like this:
  498.  
  499.      diff3 MINE OLDER YOURS
  500.  
  501. You can remember the order of the arguments by noting that they are in
  502. alphabetical order.
  503.  
  504.    You can think of this as subtracting OLDER from YOURS and adding the
  505. result to MINE, or as merging into MINE the changes that would turn
  506. OLDER into YOURS.  This merging is well-defined as long as MINE and
  507. OLDER match in the neighborhood of each such change.  This fails to be
  508. true when all three input files differ or when only OLDER differs; we
  509. call this a "conflict".  When all three input files differ, we call the
  510. conflict an "overlap".
  511.  
  512.    `diff3' gives you several ways to handle overlaps and conflicts.
  513. You can omit overlaps or conflicts, or select only overlaps, or mark
  514. conflicts with special `<<<<<<<' and `>>>>>>>' lines.
  515.  
  516.    `diff3' can output the merge results as an `ed' script that that can
  517. be applied to the first file to yield the merged output.  However, it
  518. is usually better to have `diff3' generate the merged output directly;
  519. this bypasses some problems with `ed'.
  520.  
  521. * Menu:
  522.  
  523. * Which Changes::        Selecting changes to incorporate.
  524. * Marking Conflicts::        Marking conflicts.
  525. * Bypassing ed::        Generating merged output directly.
  526. * Merging Incomplete Lines::    How `diff3' merges incomplete lines.
  527. * Saving the Changed File::    Emulating System V behavior.
  528.  
  529. 
  530. File: diff.info,  Node: Which Changes,  Next: Marking Conflicts,  Up: diff3 Merging
  531.  
  532. Selecting Which Changes to Incorporate
  533. ======================================
  534.  
  535.    You can select all unmerged changes from OLDER to YOURS for merging
  536. into MINE with the `-e' or `--ed' option.  You can select only the
  537. nonoverlapping unmerged changes with `-3' or `--easy-only', and you can
  538. select only the overlapping changes with `-x' or `--overlap-only'.
  539.  
  540.    The `-e', `-3' and `-x' options select only "unmerged changes", i.e.
  541. changes where MINE and YOURS differ; they ignore changes from OLDER to
  542. YOURS where MINE and YOURS are identical, because they assume that such
  543. changes have already been merged.  If this assumption is not a safe
  544. one, you can use the `-A' or `--show-all' option (*note Marking
  545. Conflicts::.).
  546.  
  547.    Here is the output of the command `diff3' with each of these three
  548. options (*note Sample diff3 Input::., for the complete contents of the
  549. files).  Notice that `-e' outputs the union of the disjoint sets of
  550. changes output by `-3' and `-x'.
  551.  
  552.    Output of `diff3 -e lao tzu tao':
  553.      11a
  554.      
  555.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  556.      .
  557.      8c
  558.        so we may see their result.
  559.      .
  560.  
  561.    Output of `diff3 -3 lao tzu tao':
  562.      8c
  563.        so we may see their result.
  564.      .
  565.  
  566.    Output of `diff3 -x lao tzu tao':
  567.      11a
  568.      
  569.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  570.      .
  571.  
  572. 
  573. File: diff.info,  Node: Marking Conflicts,  Next: Bypassing ed,  Prev: Which Changes,  Up: diff3 Merging
  574.  
  575. Marking Conflicts
  576. =================
  577.  
  578.    `diff3' can mark conflicts in the merged output by bracketing them
  579. with special marker lines.  A conflict that comes from two files A and
  580. B is marked as follows:
  581.  
  582.      <<<<<<< A
  583.      lines from A
  584.      =======
  585.      lines from B
  586.      >>>>>>> B
  587.  
  588.    A conflict that comes from three files A, B and C is marked as
  589. follows:
  590.  
  591.      <<<<<<< A
  592.      lines from A
  593.      ||||||| B
  594.      lines from B
  595.      =======
  596.      lines from C
  597.      >>>>>>> C
  598.  
  599.    The `-A' or `--show-all' option acts like the `-e' option, except
  600. that it brackets conflicts, and it outputs all changes from OLDER to
  601. YOURS, not just the unmerged changes.  Thus, given the sample input
  602. files (*note Sample diff3 Input::.), `diff3 -A lao tzu tao' puts
  603. brackets around the conflict where only `tzu' differs:
  604.  
  605.      <<<<<<< tzu
  606.      =======
  607.      The Way that can be told of is not the eternal Way;
  608.      The name that can be named is not the eternal name.
  609.      >>>>>>> tao
  610.  
  611.    And it outputs the three-way conflict as follows:
  612.  
  613.      <<<<<<< lao
  614.      ||||||| tzu
  615.      They both may be called deep and profound.
  616.      Deeper and more profound,
  617.      The door of all subtleties!
  618.      =======
  619.      
  620.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  621.      >>>>>>> tao
  622.  
  623.    The `-E' or `--show-overlap' option outputs less information than
  624. the `-A' or `--show-all' option, because it outputs only unmerged
  625. changes, and it never outputs the contents of the second file.  Thus
  626. the `-E' option acts like the `-e' option, except that it brackets the
  627. first and third files from three-way overlapping changes.  Similarly,
  628. `-X' acts like `-x', except it brackets all its (necessarily
  629. overlapping) changes.  For example, for the three-way overlapping
  630. change above, the `-E' and `-X' options output the following:
  631.  
  632.      <<<<<<< lao
  633.      =======
  634.      
  635.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  636.      >>>>>>> tao
  637.  
  638.    If you are comparing files that have meaningless or uninformative
  639. names, you can use the `-L LABEL' or `--label=LABEL' option to show
  640. alternate names in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets.
  641. This option can be given up to three times, once for each input file.
  642. Thus `diff3 -A -L X -L Y -L Z A B C' acts like `diff3 -A A B C', except
  643. that the output looks like it came from files named `X', `Y' and `Z'
  644. rather than from files named `A', `B' and `C'.
  645.  
  646. 
  647. File: diff.info,  Node: Bypassing ed,  Next: Merging Incomplete Lines,  Prev: Marking Conflicts,  Up: diff3 Merging
  648.  
  649. Generating the Merged Output Directly
  650. =====================================
  651.  
  652.    With the `-m' or `--merge' option, `diff3' outputs the merged file
  653. directly.  This is more efficient than using `ed' to generate it, and
  654. works even with non-text files that `ed' would reject.  If you specify
  655. `-m' without an `ed' script option, `-A' (`--show-all') is assumed.
  656.  
  657.    For example, the command `diff3 -m lao tzu tao' (*note Sample diff3
  658. Input::. for a copy of the input files) would output the following:
  659.  
  660.      <<<<<<< tzu
  661.      =======
  662.      The Way that can be told of is not the eternal Way;
  663.      The name that can be named is not the eternal name.
  664.      >>>>>>> tao
  665.      The Nameless is the origin of Heaven and Earth;
  666.      The Named is the mother of all things.
  667.      Therefore let there always be non-being,
  668.        so we may see their subtlety,
  669.      And let there always be being,
  670.        so we may see their result.
  671.      The two are the same,
  672.      But after they are produced,
  673.        they have different names.
  674.      <<<<<<< lao
  675.      ||||||| tzu
  676.      They both may be called deep and profound.
  677.      Deeper and more profound,
  678.      The door of all subtleties!
  679.      =======
  680.      
  681.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  682.      >>>>>>> tao
  683.  
  684. 
  685. File: diff.info,  Node: Merging Incomplete Lines,  Next: Saving the Changed File,  Prev: Bypassing ed,  Up: diff3 Merging
  686.  
  687. How `diff3' Merges Incomplete Lines
  688. ===================================
  689.  
  690.    With `-m', incomplete lines (*note Incomplete Lines::.) are simply
  691. copied to the output as they are found; if the merged output ends in an
  692. conflict and one of the input files ends in an incomplete line,
  693. succeeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere
  694. other than the start of a line because they are appended to the
  695. incomplete line.
  696.  
  697.    Without `-m', if an `ed' script option is specified and an
  698. incomplete line is found, `diff3' generates a warning and acts as if a
  699. newline had been present.
  700.  
  701. 
  702. File: diff.info,  Node: Saving the Changed File,  Prev: Merging Incomplete Lines,  Up: diff3 Merging
  703.  
  704. Saving the Changed File
  705. =======================
  706.  
  707.    Traditional Unix `diff3' generates an `ed' script without the
  708. trailing `w' and and `q' commands that save the changes.  System V
  709. `diff3' generates these extra commands.  GNU `diff3' normally behaves
  710. like traditional Unix `diff3', but with the `-i' option it behaves like
  711. System V `diff3' and appends the `w' and `q' commands.
  712.  
  713.    The `-i' option requires one of the `ed' script options `-AeExX3',
  714. and is incompatible with the merged output option `-m'.
  715.  
  716. 
  717. File: diff.info,  Node: Interactive Merging,  Next: Merging with patch,  Prev: diff3 Merging,  Up: Top
  718.  
  719. Interactive Merging with `sdiff'
  720. ********************************
  721.  
  722.    With `sdiff', you can merge two files interactively based on a
  723. side-by-side `-y' format comparison (*note Side by Side::.).  Use `-o
  724. FILE' or `--output=FILE' to specify where to put the merged text.
  725. *Note Invoking sdiff::, for more details on the options to `sdiff'.
  726.  
  727.    Another way to merge files interactively is to use the Emacs Lisp
  728. package `emerge'.  *Note emerge: (emacs)emerge, for more information.
  729.  
  730. * Menu:
  731.  
  732. * sdiff Option Summary::Summary of `sdiff' options.
  733. * Merge Commands::    Merging two files interactively.
  734.  
  735. 
  736. File: diff.info,  Node: sdiff Option Summary,  Next: Merge Commands,  Up: Interactive Merging
  737.  
  738. Specifying `diff' Options to `sdiff'
  739. ====================================
  740.  
  741.    The following `sdiff' options have the same meaning as for `diff'.
  742. *Note diff Options::, for the use of these options.
  743.  
  744.      -a -b -d -i -t -v
  745.      -B -H -I REGEXP
  746.      
  747.      --ignore-blank-lines  --ignore-case
  748.      --ignore-matching-lines=REGEXP  --ignore-space-change
  749.      --left-column  --minimal  --speed-large-files
  750.      --suppress-common-lines  --expand-tabs
  751.      --text  --version  --width=COLUMNS
  752.  
  753.    For historical reasons, `sdiff' has alternate names for some
  754. options.  The `-l' option is equivalent to the `--left-column' option,
  755. and similarly `-s' is equivalent to `--suppress-common-lines'.  The
  756. meaning of the `sdiff' `-w' and `-W' options is interchanged from that
  757. of `diff': with `sdiff', `-w COLUMNS' is equivalent to
  758. `--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'.
  759. `sdiff' without the `-o' option is equivalent to `diff' with the `-y'
  760. or `--side-by-side' option (*note Side by Side::.).
  761.  
  762. 
  763. File: diff.info,  Node: Merge Commands,  Prev: sdiff Option Summary,  Up: Interactive Merging
  764.  
  765. Merge Commands
  766. ==============
  767.  
  768.    Groups of common lines, with a blank gutter, are copied from the
  769. first file to the output.  After each group of differing lines, `sdiff'
  770. prompts with `%' and pauses, waiting for one of the following commands.
  771. Follow each command with RET.
  772.  
  773. `e'
  774.      Discard both versions.  Invoke a text editor on an empty temporary
  775.      file, then copy the resulting file to the output.
  776.  
  777. `eb'
  778.      Concatenate the two versions, edit the result in a temporary file,
  779.      then copy the edited result to the output.
  780.  
  781. `el'
  782.      Edit a copy of the left version, then copy the result to the
  783.      output.
  784.  
  785. `er'
  786.      Edit a copy of the right version, then copy the result to the
  787.      output.
  788.  
  789. `l'
  790.      Copy the left version to the output.
  791.  
  792. `q'
  793.      Quit.
  794.  
  795. `r'
  796.      Copy the right version to the output.
  797.  
  798. `s'
  799.      Silently copy common lines.
  800.  
  801. `v'
  802.      Verbosely copy common lines.  This is the default.
  803.  
  804.    The text editor invoked is specified by the `EDITOR' environment
  805. variable if it is set.  The default is system-dependent.
  806.  
  807. 
  808. File: diff.info,  Node: Merging with patch,  Next: Making Patches,  Prev: Interactive Merging,  Up: Top
  809.  
  810. Merging with `patch'
  811. ********************
  812.  
  813.    `patch' takes comparison output produced by `diff' and applies the
  814. differences to a copy of the original file, producing a patched
  815. version.  With `patch', you can distribute just the changes to a set of
  816. files instead of distributing the entire file set; your correspondents
  817. can apply `patch' to update their copy of the files with your changes.
  818. `patch' automatically determines the diff format, skips any leading or
  819. trailing headers, and uses the headers to determine which file to
  820. patch.  This lets your correspondents feed an article or message
  821. containing a difference listing directly to `patch'.
  822.  
  823.    `patch' detects and warns about common problems like forward
  824. patches.  It saves the original version of the files it patches, and
  825. saves any patches that it could not apply.  It can also maintain a
  826. `patchlevel.h' file to ensures that your correspondents apply diffs in
  827. the proper order.
  828.  
  829.    `patch' accepts a series of diffs in its standard input, usually
  830. separated by headers that specify which file to patch.  It applies
  831. `diff' hunks (*note Hunks::.) one by one.  If a hunk does not exactly
  832. match the original file, `patch' uses heuristics to try to patch the
  833. file as well as it can.  If no approximate match can be found, `patch'
  834. rejects the hunk and skips to the next hunk.  `patch' normally replaces
  835. each file F with its new version, saving the original file in `F.orig',
  836. and putting reject hunks (if any) into `F.rej'.
  837.  
  838.    *Note Invoking patch::, for detailed information on the options to
  839. `patch'.  *Note Backups::, for more information on how `patch' names
  840. backup files.  *Note Rejects::, for more information on where `patch'
  841. puts reject hunks.
  842.  
  843. * Menu:
  844.  
  845. * patch Input::        Selecting the type of `patch' input.
  846. * Imperfect::        Dealing with imperfect patches.
  847. * Empty Files::        Removing empty files after patching.
  848. * Multiple Patches::    Handling multiple patches in a file specially.
  849. * patch Messages::    Messages and questions `patch' can produce.
  850.  
  851. 
  852. File: diff.info,  Node: patch Input,  Next: Imperfect,  Up: Merging with patch
  853.  
  854. Selecting the `patch' Input Format
  855. ==================================
  856.  
  857.    `patch' normally determines which `diff' format the patch file uses
  858. by examining its contents.  For patch files that contain particularly
  859. confusing leading text, you might need to use one of the following
  860. options to force `patch' to interpret the patch file as a certain
  861. format of diff.  The output formats listed here are the only ones that
  862. `patch' can understand.
  863.  
  864. `-c'
  865. `--context'
  866.      context diff.
  867.  
  868. `-e'
  869. `--ed'
  870.      `ed' script.
  871.  
  872. `-n'
  873. `--normal'
  874.      normal diff.
  875.  
  876. `-u'
  877. `--unified'
  878.      unified diff.
  879.  
  880. 
  881. File: diff.info,  Node: Imperfect,  Next: Empty Files,  Prev: patch Input,  Up: Merging with patch
  882.  
  883. Applying Imperfect Patches
  884. ==========================
  885.  
  886.    `patch' tries to skip any leading text in the patch file, apply the
  887. diff, and then skip any trailing text.  Thus you can feed a news article
  888. or mail message directly to `patch', and it should work.  If the entire
  889. diff is indented by a constant amount of whitespace, `patch'
  890. automatically ignores the indentation.
  891.  
  892.    However, certain other types of imperfect input require user
  893. intervention.
  894.  
  895. * Menu:
  896.  
  897. * Changed Whitespace::    When tabs and spaces don't match exactly.
  898. * Reversed Patches::    Applying reversed patches correctly.
  899. * Inexact::        Helping `patch' find close matches.
  900.  
  901. 
  902. File: diff.info,  Node: Changed Whitespace,  Next: Reversed Patches,  Up: Imperfect
  903.  
  904. Applying Patches with Changed Whitespace
  905. ----------------------------------------
  906.  
  907.    Sometimes mailers, editors, or other programs change spaces into
  908. tabs, or vice versa.  If this happens to a patch file or an input file,
  909. the files might look the same, but `patch' will not be able to match
  910. them properly.  If this problem occurs, use the `-l' or
  911. `--ignore-whitespace' option, which makes `patch' compare whitespace
  912. loosely so that any sequence of whitespace in the patch file matches
  913. any sequence of whitespace in the input files.  Non-whitespace
  914. characters must still match exactly.  Each line of the context must
  915. still match a line in the input file.
  916.  
  917. 
  918. File: diff.info,  Node: Reversed Patches,  Next: Inexact,  Prev: Changed Whitespace,  Up: Imperfect
  919.  
  920. Applying Reversed Patches
  921. -------------------------
  922.  
  923.    Sometimes people run `diff' with the new file first instead of
  924. second.  This creates a diff that is "reversed".  To apply such
  925. patches, give `patch' the `-R' or `--reverse' option.  `patch' then
  926. attempts to swap each hunk around before applying it.  Rejects come out
  927. in the swapped format.  The `-R' option does not work with `ed' scripts
  928. because there is too little information in them to reconstruct the
  929. reverse operation.
  930.  
  931.    Often `patch' can guess that the patch is reversed.  If the first
  932. hunk of a patch fails, `patch' reverses the hunk to see if it can apply
  933. it that way.  If it can, `patch' asks you if you want to have the `-R'
  934. option set; if it can't, `patch' continues to apply the patch normally.
  935. This method cannot detect a reversed patch if it is a normal diff and
  936. the first command is an append (which should have been a delete) since
  937. appends always succeed, because a null context matches anywhere.  But
  938. most patches add or change lines rather than delete them, so most
  939. reversed normal diffs begin with a delete, which fails, and `patch'
  940. notices.
  941.  
  942.    If you apply a patch that you have already applied, `patch' thinks
  943. it is a reversed patch and offers to un-apply the patch.  This could be
  944. construed as a feature.  If you did this inadvertently and you don't
  945. want to un-apply the patch, just answer `n' to this offer and to the
  946. subsequent "apply anyway" question--or type `C-c' to kill the `patch'
  947. process.
  948.  
  949. 
  950. File: diff.info,  Node: Inexact,  Prev: Reversed Patches,  Up: Imperfect
  951.  
  952. Helping `patch' Find Inexact Matches
  953. ------------------------------------
  954.  
  955.    For context diffs, and to a lesser extent normal diffs, `patch' can
  956. detect when the line numbers mentioned in the patch are incorrect, and
  957. it attempts to find the correct place to apply each hunk of the patch.
  958. As a first guess, it takes the line number mentioned in the hunk, plus
  959. or minus any offset used in applying the previous hunk.  If that is not
  960. the correct place, `patch' scans both forward and backward for a set of
  961. lines matching the context given in the hunk.
  962.  
  963.    First `patch' looks for a place where all lines of the context
  964. match.  If it cannot find such a place, and it is reading a context or
  965. unified diff, and the maximum fuzz factor is set to 1 or more, then
  966. `patch' makes another scan, ignoring the first and last line of
  967. context.  If that fails, and the maximum fuzz factor is set to 2 or
  968. more, it makes another scan, ignoring the first two and last two lines
  969. of context are ignored.  It continues similarly if the maximum fuzz
  970. factor is larger.
  971.  
  972.    The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor
  973. to LINES.  This option only applies to context and unified diffs; it
  974. ignores up to LINES lines while looking for the place to install a
  975. hunk.  Note that a larger fuzz factor increases the odds of making a
  976. faulty patch.  The default fuzz factor is 2; it may not be set to more
  977. than the number of lines of context in the diff, ordinarily 3.
  978.  
  979.    If `patch' cannot find a place to install a hunk of the patch, it
  980. writes the hunk out to a reject file (*note Rejects::., for information
  981. on how reject files are named).  It writes out rejected hunks in context
  982. format no matter what form the input patch is in.  If the input is a
  983. normal or `ed' diff, many of the contexts are simply null.  The line
  984. numbers on the hunks in the reject file may be different from those in
  985. the patch file: they show the approximate location where `patch' thinks
  986. the failed hunks belong in the new file rather than in the old one.
  987.  
  988.    As it completes each hunk, `patch' tells you whether the hunk
  989. succeeded or failed, and if it failed, on which line (in the new file)
  990. `patch' thinks the hunk should go.  If this is different from the line
  991. number specified in the diff, it tells you the offset.  A single large
  992. offset *may* indicate that `patch' installed a hunk in the wrong place.
  993. `patch' also tells you if it used a fuzz factor to make the match, in
  994. which case you should also be slightly suspicious.
  995.  
  996.    `patch' cannot tell if the line numbers are off in an `ed' script,
  997. and can only detect wrong line numbers in a normal diff when it finds a
  998. change or delete command.  It may have the same problem with a context
  999. diff using a fuzz factor equal to or greater than the number of lines
  1000. of context shown in the diff (typically 3).  In these cases, you should
  1001. probably look at a context diff between your original and patched input
  1002. files to see if the changes make sense.  Compiling without errors is a
  1003. pretty good indication that the patch worked, but not a guarantee.
  1004.  
  1005.    `patch' usually produces the correct results, even when it must make
  1006. many guesses.  However, the results are guaranteed only when the patch
  1007. is applied to an exact copy of the file that the patch was generated
  1008. from.
  1009.  
  1010. 
  1011. File: diff.info,  Node: Empty Files,  Next: Multiple Patches,  Prev: Imperfect,  Up: Merging with patch
  1012.  
  1013. Removing Empty Files
  1014. ====================
  1015.  
  1016.    Sometimes when comparing two directories, the first directory
  1017. contains a file that the second directory does not.  If you give `diff'
  1018. the `-N' or `--new-file' option, it outputs a diff that deletes the
  1019. contents of this file.  By default, `patch' leaves an empty file after
  1020. applying such a diff.  The `-E' or `--remove-empty-files' option to
  1021. `patch' deletes output files that are empty after applying the diff.
  1022.  
  1023. 
  1024. File: diff.info,  Node: Multiple Patches,  Next: patch Messages,  Prev: Empty Files,  Up: Merging with patch
  1025.  
  1026. Multiple Patches in a File
  1027. ==========================
  1028.  
  1029.    If the patch file contains more than one patch, `patch' tries to
  1030. apply each of them as if they came from separate patch files.  This
  1031. means that it determines the name of the file to patch for each patch,
  1032. and that it examines the leading text before each patch for file names
  1033. and prerequisite revision level (*note Making Patches::., for more on
  1034. that topic).
  1035.  
  1036.    For the second and subsequent patches in the patch file, you can give
  1037. options and another original file name by separating their argument
  1038. lists with a `+'.  However, the argument list for a second or
  1039. subsequent patch may not specify a new patch file, since that does not
  1040. make sense.
  1041.  
  1042.    For example, to tell `patch' to strip the first three slashes from
  1043. the name of the first patch in the patch file and none from subsequent
  1044. patches, and to use `code.c' as the first input file, you can use:
  1045.  
  1046.      patch -p3 code.c + -p0 < patchfile
  1047.  
  1048.    The `-S' or `--skip' option ignores the current patch from the patch
  1049. file, but continue looking for the next patch in the file.  Thus, to
  1050. ignore the first and third patches in the patch file, you can use:
  1051.  
  1052.      patch -S + + -S + < patch file
  1053.  
  1054. 
  1055. File: diff.info,  Node: patch Messages,  Prev: Multiple Patches,  Up: Merging with patch
  1056.  
  1057. Messages and Questions from `patch'
  1058. ===================================
  1059.  
  1060.    `patch' can produce a variety of messages, especially if it has
  1061. trouble decoding its input.  In a few situations where it's not sure how
  1062. to proceed, `patch' normally prompts you for more information from the
  1063. keyboard.  There are options to suppress printing non-fatal messages
  1064. and stopping for keyboard input.
  1065.  
  1066.    The message `Hmm...' indicates that `patch' is reading text in the
  1067. patch file, attempting to determine whether there is a patch in that
  1068. text, and if so, what kind of patch it is.
  1069.  
  1070.    You can inhibit all terminal output from `patch', unless an error
  1071. occurs, by using the `-s', `--quiet', or `--silent' option.
  1072.  
  1073.    There are two ways you can prevent `patch' from asking you any
  1074. questions.  The `-f' or `--force' option assumes that you know what you
  1075. are doing.  It assumes the following:
  1076.  
  1077.    * skip patches for which it can't find a file to patch;
  1078.  
  1079.    * patch files even though they have the wrong version for the
  1080.      `Prereq:' line in the patch;
  1081.  
  1082.    * assume that patches are not reversed even if they look like they
  1083.      are.
  1084.  
  1085.    The `-t' or `--batch' option is similar to `-f', in that it
  1086. suppresses questions, but it makes somewhat different assumptions:
  1087.  
  1088.    * skip patches for which it can't find a file to patch (the same as
  1089.      `-f');
  1090.  
  1091.    * skip patches for which the file has the wrong version for the
  1092.      `Prereq:' line in the patch;
  1093.  
  1094.    * assume that patches are reversed if they look like they are.
  1095.  
  1096.    `patch' exits with a non-zero status if it creates any reject files.
  1097. When applying a set of patches in a loop, you should check the exit
  1098. status, so you don't apply a later patch to a partially patched file.
  1099.  
  1100. 
  1101. File: diff.info,  Node: Making Patches,  Next: Invoking cmp,  Prev: Merging with patch,  Up: Top
  1102.  
  1103. Tips for Making Patch Distributions
  1104. ***********************************
  1105.  
  1106.    Here are some things you should keep in mind if you are going to
  1107. distribute patches for updating a software package.
  1108.  
  1109.    Make sure you have specified the file names correctly, either in a
  1110. context diff header or with an `Index:' line.  If you are patching
  1111. files in a subdirectory, be sure to tell the patch user to specify a
  1112. `-p' or `--strip' option as needed.  Take care to not send out reversed
  1113. patches, since these make people wonder whether they have already
  1114. applied the patch.
  1115.  
  1116.    To save people from partially applying a patch before other patches
  1117. that should have gone before it, you can make the first patch in the
  1118. patch file update a file with a name like `patchlevel.h' or
  1119. `version.c', which contains a patch level or version number.  If the
  1120. input file contains the wrong version number, `patch' will complain
  1121. immediately.
  1122.  
  1123.    An even clearer way to prevent this problem is to put a `Prereq:'
  1124. line before the patch.  If the leading text in the patch file contains a
  1125. line that starts with `Prereq:', `patch' takes the next word from that
  1126. line (normally a version number) and checks whether the next input file
  1127. contains that word, preceded and followed by either whitespace or a
  1128. newline.  If not, `patch' prompts you for confirmation before
  1129. proceeding.  This makes it difficult to accidentally apply patches in
  1130. the wrong order.
  1131.  
  1132.    Since `patch' does not handle incomplete lines properly, make sure
  1133. that all the source files in your program end with a newline whenever
  1134. you release a version.
  1135.  
  1136.    To create a patch that changes an older version of a package into a
  1137. newer version, first make a copy of the older version in a scratch
  1138. directory.  Typically you do that by unpacking a `tar' or `shar'
  1139. archive of the older version.
  1140.  
  1141.    You might be able to reduce the size of the patch by renaming or
  1142. removing some files before making the patch.  If the older version of
  1143. the package contains any files that the newer version does not, or if
  1144. any files have been renamed between the two versions, make a list of
  1145. `rm' and `mv' commands for the user to execute in the old version
  1146. directory before applying the patch.  Then run those commands yourself
  1147. in the scratch directory.
  1148.  
  1149.    If there are any files that you don't need to include in the patch
  1150. because they can easily be rebuilt from other files (for example,
  1151. `TAGS' and output from `yacc' and `makeinfo'), replace the versions in
  1152. the scratch directory with the newer versions, using `rm' and `ln' or
  1153. `cp'.
  1154.  
  1155.    Now you can create the patch.  The de-facto standard `diff' format
  1156. for patch distributions is context format with two lines of context,
  1157. produced by giving `diff' the `-C 2' option.  Give `diff' the `-N'
  1158. option in case the newer version of the package contains any files that
  1159. the older one does not.  Make sure to specify the scratch directory
  1160. first and the newer directory second.
  1161.  
  1162.    Add to the top of the patch a note telling the user any `rm' and
  1163. `mv' commands to run before applying the patch.  Then you can remove
  1164. the scratch directory.
  1165.  
  1166. 
  1167. File: diff.info,  Node: Invoking cmp,  Next: Invoking diff,  Prev: Making Patches,  Up: Top
  1168.  
  1169. Invoking `cmp'
  1170. **************
  1171.  
  1172.    The `cmp' command compares two files, and if they differ, tells the
  1173. first byte and line number where they differ.  Its arguments are as
  1174. follows:
  1175.  
  1176.      cmp OPTIONS... FROM-FILE [TO-FILE]
  1177.  
  1178.    The file name `-' is always the standard input.  `cmp' also uses the
  1179. standard input if one file name is omitted.
  1180.  
  1181.    An exit status of 0 means no differences were found, 1 means some
  1182. differences were found, and 2 means trouble.
  1183.  
  1184. * Menu:
  1185.  
  1186. * cmp Options::        Summary of options to `cmp'.
  1187.  
  1188. 
  1189. File: diff.info,  Node: cmp Options,  Up: Invoking cmp
  1190.  
  1191. Options to `cmp'
  1192. ================
  1193.  
  1194.    Below is a summary of all of the options that GNU `cmp' accepts.
  1195. Most options have two equivalent names, one of which is a single letter
  1196. preceded by `-', and the other of which is a long name preceded by
  1197. `--'.  Multiple single letter options (unless they take an argument)
  1198. can be combined into a single command line word: `-cl' is equivalent to
  1199. `-c -l'.
  1200.  
  1201. `-c'
  1202.      Print the differing characters.  Display control characters as a
  1203.      `^' followed by a letter of the alphabet and precede characters
  1204.      that have the high bit set with `M-' (which stands for "meta").
  1205.  
  1206. `-l'
  1207.      Print the (decimal) offsets and (octal) values of all differing
  1208.      bytes.
  1209.  
  1210. `--print-chars'
  1211.      Print the differing characters.  Display control characters as a
  1212.      `^' followed by a letter of the alphabet and precede characters
  1213.      that have the high bit set with `M-' (which stands for "meta").
  1214.  
  1215. `--quiet'
  1216. `-s'
  1217. `--silent'
  1218.      Do not print anything; only return an exit status indicating
  1219.      whether the files differ.
  1220.  
  1221. `--verbose'
  1222.      Print the (decimal) offsets and (octal) values of all differing
  1223.      bytes.
  1224.  
  1225. 
  1226. File: diff.info,  Node: Invoking diff,  Next: Invoking diff3,  Prev: Invoking cmp,  Up: Top
  1227.  
  1228. Invoking `diff'
  1229. ***************
  1230.  
  1231.    The format for running the `diff' command is:
  1232.  
  1233.      diff OPTIONS... FROM-FILE TO-FILE
  1234.  
  1235.    In the simplest case, `diff' compares the contents of the two files
  1236. FROM-FILE and TO-FILE.  A file name of `-' stands for text read from
  1237. the standard input.  As a special case, `diff - -' compares a copy of
  1238. standard input to itself.
  1239.  
  1240.    If FROM-FILE is a directory and TO-FILE is not, `diff' compares the
  1241. file in FROM-FILE whose file name is that of TO-FILE, and vice versa.
  1242. The non-directory file must not be `-'.
  1243.  
  1244.    If both FROM-FILE and TO-FILE are directories, `diff' compares
  1245. corresponding files in both directories, in alphabetical order; this
  1246. comparison is not recursive unless the `-r' or `--recursive' option is
  1247. given.  `diff' never compares the actual contents of a directory as if
  1248. it were a file.  The file that is fully specified may not be standard
  1249. input, because standard input is nameless and the notion of "file with
  1250. the same name" does not apply.
  1251.  
  1252.    `diff' options begin with `-', so normally FROM-FILE and TO-FILE may
  1253. not begin with `-'.  However, `--' as an argument by itself treats the
  1254. remaining arguments as file names even if they begin with `-'.
  1255.  
  1256.    An exit status of 0 means no differences were found, 1 means some
  1257. differences were found, and 2 means trouble.
  1258.  
  1259. * Menu:
  1260.  
  1261. * diff Options::    Summary of options to `diff'.
  1262.  
  1263.