home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs567x.zip / doc / diff.info (.txt) < prev    next >
GNU Info File  |  1994-06-24  |  152KB  |  3,080 lines

  1. This is Info file diff.info, produced by Makeinfo-1.55 from the input
  2. file diff.texi.
  3.    This file documents the the GNU `diff', `diff3', `sdiff', and `cmp'
  4. commands for showing the differences between text files and the `patch'
  5. command for using their output to update files.
  6.    Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that this permission notice may be stated in a
  17. translation approved by the Foundation.
  18. File: diff.info,  Node: Top,  Up: (dir)
  19.    This file documents the the GNU `diff', `diff3', `sdiff', and `cmp'
  20. commands for showing the differences between text files and the `patch'
  21. command for using their output to update files.
  22.    This is Edition 1.2, for `diff' 2.4 and `patch' 2.1.
  23. * Menu:
  24. * Overview::        Preliminary information.
  25. * Comparison::        What file comparison means.
  26. * Output Formats::    Formats for difference reports.
  27. * Comparing Directories::    Comparing files and directories.
  28. * Adjusting Output::    Making `diff' output prettier.
  29. * diff Performance::    Making `diff' smarter or faster.
  30. * Comparing Three Files:: Formats for three-way difference reports.
  31. * diff3 Merging::    Merging from a common ancestor.
  32. * Interactive Merging::    Interactive merging with `sdiff'.
  33. * Merging with patch::    Using `patch' to change old files into new ones.
  34. * Making Patches::    Tips for making patch distributions.
  35. * Invoking cmp::    How to run `cmp' and a summary of its options.
  36. * Invoking diff::    How to run `diff' and a summary of its options.
  37. * Invoking diff3::    How to run `diff3' and a summary of its options.
  38. * Invoking patch::    How to run `patch' and a summary of its options.
  39. * Invoking sdiff::    How to run `sdiff' and a summary of its options.
  40. * Incomplete Lines::    Lines that lack trailing newlines.
  41. * Projects::        If you think you've found a bug or other shortcoming.
  42. * Concept Index::    Index of concepts.
  43. File: diff.info,  Node: Overview,  Next: Comparison,  Up: Top
  44. Overview
  45. ********
  46.    Computer users often find occasion to ask how two files differ.
  47. Perhaps one file is a newer version of the other file.  Or maybe the
  48. two files started out as identical copies but were changed by different
  49. people.
  50.    You can use the `diff' command to show differences between two
  51. files, or each corresponding file in two directories.  `diff' outputs
  52. differences between files line by line in any of several formats,
  53. selectable by command line options.  This set of differences is often
  54. called a "diff" or "patch".  For files that are identical, `diff'
  55. normally produces no output; for binary (non-text) files, `diff'
  56. normally reports only that they are different.
  57.    You can use the `cmp' command to show the offsets and line numbers
  58. where two files differ.  `cmp' can also show all the characters that
  59. differ between the two files, side by side.  Another way to compare two
  60. files character by character is the Emacs command `M-x
  61. compare-windows'.  *Note Other Window: (emacs)Other Window, for more
  62. information on that command.
  63.    You can use the `diff3' command to show differences among three
  64. files.  When two people have made independent changes to a common
  65. original, `diff3' can report the differences between the original and
  66. the two changed versions, and can produce a merged file that contains
  67. both persons' changes together with warnings about conflicts.
  68.    You can use the `sdiff' command to merge two files interactively.
  69.    You can use the set of differences produced by `diff' to distribute
  70. updates to text files (such as program source code) to other people.
  71. This method is especially useful when the differences are small compared
  72. to the complete files.  Given `diff' output, you can use the `patch'
  73. program to update, or "patch", a copy of the file.  If you think of
  74. `diff' as subtracting one file from another to produce their
  75. difference, you can think of `patch' as adding the difference to one
  76. file to reproduce the other.
  77.    This manual first concentrates on making diffs, and later shows how
  78. to use diffs to update files.
  79.    GNU `diff' was written by Mike Haertel, David Hayes, Richard
  80. Stallman, Len Tower, and Paul Eggert.  Wayne Davison designed and
  81. implemented the unified output format.  The basic algorithm is described
  82. in "An O(ND) Difference Algorithm and its Variations", Eugene W. Myers,
  83. `Algorithmica' Vol. 1 No. 2, 1986, pp. 251-266; and in "A File
  84. Comparison Program", Webb Miller and Eugene W. Myers,
  85. `Software--Practice and Experience' Vol. 15 No. 11, 1985, pp. 1025-1040.
  86. The algorithm was independently discovered as described in "Algorithms
  87. for Approximate String Matching", E. Ukkonen, `Information and Control'
  88. Vol. 64, 1985, pp. 100-118.
  89.    GNU `diff3' was written by Randy Smith.  GNU `sdiff' was written by
  90. Thomas Lord.  GNU `cmp' was written by Torbjorn Granlund and David
  91. MacKenzie.
  92.    `patch' was written mainly by Larry Wall; the GNU enhancements were
  93. written mainly by Wayne Davison and David MacKenzie.  Parts of this
  94. manual are adapted from a manual page written by Larry Wall, with his
  95. permission.
  96. File: diff.info,  Node: Comparison,  Next: Output Formats,  Prev: Overview,  Up: Top
  97. What Comparison Means
  98. *********************
  99.    There are several ways to think about the differences between two
  100. files.  One way to think of the differences is as a series of lines
  101. that were deleted from, inserted in, or changed in one file to produce
  102. the other file.  `diff' compares two files line by line, finds groups of
  103. lines that differ, and reports each group of differing lines.  It can
  104. report the differing lines in several formats, which have different
  105. purposes.
  106.    GNU `diff' can show whether files are different without detailing
  107. the differences.  It also provides ways to suppress certain kinds of
  108. differences that are not important to you.  Most commonly, such
  109. differences are changes in the amount of white space between words or
  110. lines.  `diff' also provides ways to suppress differences in alphabetic
  111. case or in lines that match a regular expression that you provide.
  112. These options can accumulate; for example, you can ignore changes in
  113. both white space and alphabetic case.
  114.    Another way to think of the differences between two files is as a
  115. sequence of pairs of characters that can be either identical or
  116. different.  `cmp' reports the differences between two files character
  117. by character, instead of line by line.  As a result, it is more useful
  118. than `diff' for comparing binary files.  For text files, `cmp' is
  119. useful mainly when you want to know only whether two files are
  120. identical.
  121.    To illustrate the effect that considering changes character by
  122. character can have compared with considering them line by line, think
  123. of what happens if a single newline character is added to the beginning
  124. of a file.  If that file is then compared with an otherwise identical
  125. file that lacks the newline at the beginning, `diff' will report that a
  126. blank line has been added to the file, while `cmp' will report that
  127. almost every character of the two files differs.
  128.    `diff3' normally compares three input files line by line, finds
  129. groups of lines that differ, and reports each group of differing lines.
  130. Its output is designed to make it easy to inspect two different sets of
  131. changes to the same file.
  132. * Menu:
  133. * Hunks::        Groups of differing lines.
  134. * White Space::        Suppressing differences in white space.
  135. * Blank Lines::        Suppressing differences in blank lines.
  136. * Case Folding::    Suppressing differences in alphabetic case.
  137. * Specified Folding::    Suppressing differences that match regular expressions.
  138. * Brief::        Summarizing which files are different.
  139. * Binary::        Comparing binary files or forcing text comparisons.
  140. File: diff.info,  Node: Hunks,  Next: White Space,  Up: Comparison
  141. Hunks
  142. =====
  143.    When comparing two files, `diff' finds sequences of lines common to
  144. both files, interspersed with groups of differing lines called "hunks".
  145. Comparing two identical files yields one sequence of common lines and
  146. no hunks, because no lines differ.  Comparing two entirely different
  147. files yields no common lines and one large hunk that contains all lines
  148. of both files.  In general, there are many ways to match up lines
  149. between two given files.  `diff' tries to minimize the total hunk size
  150. by finding large sequences of common lines interspersed with small
  151. hunks of differing lines.
  152.    For example, suppose the file `F' contains the three lines `a', `b',
  153. `c', and the file `G' contains the same three lines in reverse order
  154. `c', `b', `a'.  If `diff' finds the line `c' as common, then the command
  155. `diff F G' produces this output:
  156.      1,2d0
  157.      < a
  158.      < b
  159.      3a2,3
  160.      > b
  161.      > a
  162. But if `diff' notices the common line `b' instead, it produces this
  163. output:
  164.      1c1
  165.      < a
  166.      ---
  167.      > c
  168.      3c3
  169.      < c
  170.      ---
  171.      > a
  172. It is also possible to find `a' as the common line.  `diff' does not
  173. always find an optimal matching between the files; it takes shortcuts
  174. to run faster.  But its output is usually close to the shortest
  175. possible.  You can adjust this tradeoff with the `--minimal' option
  176. (*note diff Performance::.).
  177. File: diff.info,  Node: White Space,  Next: Blank Lines,  Prev: Hunks,  Up: Comparison
  178. Suppressing Differences in Blank and Tab Spacing
  179. ================================================
  180.    The `-b' and `--ignore-space-change' options ignore white space at
  181. line end, and considers all other sequences of one or more white space
  182. characters to be equivalent.  With these options, `diff' considers the
  183. following two lines to be equivalent, where `$' denotes the line end:
  184.      Here lyeth  muche rychnesse  in lytell space.   -- John Heywood$
  185.      Here lyeth muche rychnesse in lytell space. -- John Heywood   $
  186.    The `-w' and `--ignore-all-space' options are stronger than `-b'.
  187. They ignore difference even if one file has white space where the other
  188. file has none.  "White space" characters include tab, vertical tab,
  189. form feed, carriage return, and space; some locales may define
  190. additional characters to be white space.  With these options, `diff'
  191. considers the following two lines to be equivalent, where `$' denotes
  192. the line end and `^M' denotes a carriage return:
  193.      Here lyeth  muche  rychnesse in lytell space.--  John Heywood$
  194.        He relyeth much erychnes  seinly tells pace.  --John Heywood   ^M$
  195. File: diff.info,  Node: Blank Lines,  Next: Case Folding,  Prev: White Space,  Up: Comparison
  196. Suppressing Differences in Blank Lines
  197. ======================================
  198.    The `-B' and `--ignore-blank-lines' options ignore insertions or
  199. deletions of blank lines.  These options normally affect only lines
  200. that are completely empty; they do not affect lines that look empty but
  201. contain space or tab characters.  With these options, for example, a
  202. file containing
  203.      1.  A point is that which has no part.
  204.      
  205.      2.  A line is breadthless length.
  206.      -- Euclid, The Elements, I
  207. is considered identical to a file containing
  208.      1.  A point is that which has no part.
  209.      2.  A line is breadthless length.
  210.      
  211.      
  212.      -- Euclid, The Elements, I
  213. File: diff.info,  Node: Case Folding,  Next: Specified Folding,  Prev: Blank Lines,  Up: Comparison
  214. Suppressing Case Differences
  215. ============================
  216.    GNU `diff' can treat lowercase letters as equivalent to their
  217. uppercase counterparts, so that, for example, it considers `Funky
  218. Stuff', `funky STUFF', and `fUNKy stuFf' to all be the same.  To
  219. request this, use the `-i' or `--ignore-case' option.
  220. File: diff.info,  Node: Specified Folding,  Next: Brief,  Prev: Case Folding,  Up: Comparison
  221. Suppressing Lines Matching a Regular Expression
  222. ===============================================
  223.    To ignore insertions and deletions of lines that match a regular
  224. expression, use the `-I REGEXP' or `--ignore-matching-lines=REGEXP'
  225. option.  You should escape regular expressions that contain shell
  226. metacharacters to prevent the shell from expanding them.  For example,
  227. `diff -I '^[0-9]'' ignores all changes to lines beginning with a digit.
  228.    However, `-I' only ignores the insertion or deletion of lines that
  229. contain the regular expression if every changed line in the hunk--every
  230. insertion and every deletion--matches the regular expression.  In other
  231. words, for each nonignorable change, `diff' prints the complete set of
  232. changes in its vicinity, including the ignorable ones.
  233.    You can specify more than one regular expression for lines to ignore
  234. by using more than one `-I' option.  `diff' tries to match each line
  235. against each regular expression, starting with the last one given.
  236. File: diff.info,  Node: Brief,  Next: Binary,  Prev: Specified Folding,  Up: Comparison
  237. Summarizing Which Files Differ
  238. ==============================
  239.    When you only want to find out whether files are different, and you
  240. don't care what the differences are, you can use the summary output
  241. format.  In this format, instead of showing the differences between the
  242. files, `diff' simply reports whether files differ.  The `-q' and
  243. `--brief' options select this output format.
  244.    This format is especially useful when comparing the contents of two
  245. directories.  It is also much faster than doing the normal line by line
  246. comparisons, because `diff' can stop analyzing the files as soon as it
  247. knows that there are any differences.
  248.    You can also get a brief indication of whether two files differ by
  249. using `cmp'.  For files that are identical, `cmp' produces no output.
  250. When the files differ, by default, `cmp' outputs the byte offset and
  251. line number where the first difference occurs.  You can use the `-s'
  252. option to suppress that information, so that `cmp' produces no output
  253. and reports whether the files differ using only its exit status (*note
  254. Invoking cmp::.).
  255.    Unlike `diff', `cmp' cannot compare directories; it can only compare
  256. two files.
  257. File: diff.info,  Node: Binary,  Prev: Brief,  Up: Comparison
  258. Binary Files and Forcing Text Comparisons
  259. =========================================
  260.    If `diff' thinks that either of the two files it is comparing is
  261. binary (a non-text file), it normally treats that pair of files much as
  262. if the summary output format had been selected (*note Brief::.), and
  263. reports only that the binary files are different.  This is because line
  264. by line comparisons are usually not meaningful for binary files.
  265.    `diff' determines whether a file is text or binary by checking the
  266. first few bytes in the file; the exact number of bytes is system
  267. dependent, but it is typically several thousand.  If every character in
  268. that part of the file is non-null, `diff' considers the file to be
  269. text; otherwise it considers the file to be binary.
  270.    Sometimes you might want to force `diff' to consider files to be
  271. text.  For example, you might be comparing text files that contain null
  272. characters; `diff' would erroneously decide that those are non-text
  273. files.  Or you might be comparing documents that are in a format used
  274. by a word processing system that uses null characters to indicate
  275. special formatting.  You can force `diff' to consider all files to be
  276. text files, and compare them line by line, by using the `-a' or
  277. `--text' option.  If the files you compare using this option do not in
  278. fact contain text, they will probably contain few newline characters,
  279. and the `diff' output will consist of hunks showing differences between
  280. long lines of whatever characters the files contain.
  281.    You can also force `diff' to consider all files to be binary files,
  282. and report only whether they differ (but not how).  Use the `--brief'
  283. option for this.
  284.    If you want to compare two files byte by byte, you can use the `cmp'
  285. program with the `-l' option to show the values of each differing byte
  286. in the two files.  With GNU `cmp', you can also use the `-c' option to
  287. show the ASCII representation of those bytes.  *Note Invoking cmp::,
  288. for more information.
  289.    If `diff3' thinks that any of the files it is comparing is binary (a
  290. non-text file), it normally reports an error, because such comparisons
  291. are usually not useful.  `diff3' uses the same test as `diff' to decide
  292. whether a file is binary.  As with `diff', if the input files contain a
  293. few non-text characters but otherwise are like text files, you can
  294. force `diff3' to consider all files to be text files and compare them
  295. line by line by using the `-a' or `--text' options.
  296. File: diff.info,  Node: Output Formats,  Next: Comparing Directories,  Prev: Comparison,  Up: Top
  297. `diff' Output Formats
  298. *********************
  299.    `diff' has several mutually exclusive options for output format.
  300. The following sections describe each format, illustrating how `diff'
  301. reports the differences between two sample input files.
  302. * Menu:
  303. * Sample diff Input::    Sample `diff' input files for examples.
  304. * Normal::        Showing differences without surrounding text.
  305. * Context::        Showing differences with the surrounding text.
  306. * Side by Side::        Showing differences in two columns.
  307. * Scripts::        Generating scripts for other programs.
  308. * If-then-else::    Merging files with if-then-else.
  309. File: diff.info,  Node: Sample diff Input,  Next: Normal,  Up: Output Formats
  310. Two Sample Input Files
  311. ======================
  312.    Here are two sample files that we will use in numerous examples to
  313. illustrate the output of `diff' and how various options can change it.
  314.    This is the file `lao':
  315.      The Way that can be told of is not the eternal Way;
  316.      The name that can be named is not the eternal name.
  317.      The Nameless is the origin of Heaven and Earth;
  318.      The Named is the mother of all things.
  319.      Therefore let there always be non-being,
  320.        so we may see their subtlety,
  321.      And let there always be being,
  322.        so we may see their outcome.
  323.      The two are the same,
  324.      But after they are produced,
  325.        they have different names.
  326.    This is the file `tzu':
  327.      The Nameless is the origin of Heaven and Earth;
  328.      The named is the mother of all things.
  329.      
  330.      Therefore let there always be non-being,
  331.        so we may see their subtlety,
  332.      And let there always be being,
  333.        so we may see their outcome.
  334.      The two are the same,
  335.      But after they are produced,
  336.        they have different names.
  337.      They both may be called deep and profound.
  338.      Deeper and more profound,
  339.      The door of all subtleties!
  340.    In this example, the first hunk contains just the first two lines of
  341. `lao', the second hunk contains the fourth line of `lao' opposing the
  342. second and third lines of `tzu', and the last hunk contains just the
  343. last three lines of `tzu'.
  344. File: diff.info,  Node: Normal,  Next: Context,  Prev: Sample diff Input,  Up: Output Formats
  345. Showing Differences Without Context
  346. ===================================
  347.    The "normal" `diff' output format shows each hunk of differences
  348. without any surrounding context.  Sometimes such output is the clearest
  349. way to see how lines have changed, without the clutter of nearby
  350. unchanged lines (although you can get similar results with the context
  351. or unified formats by using 0 lines of context).  However, this format
  352. is no longer widely used for sending out patches; for that purpose, the
  353. context format (*note Context Format::.) and the unified format (*note
  354. Unified Format::.) are superior.  Normal format is the default for
  355. compatibility with older versions of `diff' and the Posix standard.
  356. * Menu:
  357. * Detailed Normal::    A detailed description of normal output format.
  358. * Example Normal::    Sample output in the normal format.
  359. File: diff.info,  Node: Detailed Normal,  Next: Example Normal,  Up: Normal
  360. Detailed Description of Normal Format
  361. -------------------------------------
  362.    The normal output format consists of one or more hunks of
  363. differences; each hunk shows one area where the files differ.  Normal
  364. format hunks look like this:
  365.      CHANGE-COMMAND
  366.      < FROM-FILE-LINE
  367.      < FROM-FILE-LINE...
  368.      ---
  369.      > TO-FILE-LINE
  370.      > TO-FILE-LINE...
  371.    There are three types of change commands.  Each consists of a line
  372. number or comma-separated range of lines in the first file, a single
  373. character indicating the kind of change to make, and a line number or
  374. comma-separated range of lines in the second file.  All line numbers are
  375. the original line numbers in each file.  The types of change commands
  376. `LaR'
  377.      Add the lines in range R of the second file after line L of the
  378.      first file.  For example, `8a12,15' means append lines 12-15 of
  379.      file 2 after line 8 of file 1; or, if changing file 2 into file 1,
  380.      delete lines 12-15 of file 2.
  381. `FcT'
  382.      Replace the lines in range F of the first file with lines in range
  383.      T of the second file.  This is like a combined add and delete, but
  384.      more compact.  For example, `5,7c8,10' means change lines 5-7 of
  385.      file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
  386.      file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.
  387. `RdL'
  388.      Delete the lines in range R from the first file; line L is where
  389.      they would have appeared in the second file had they not been
  390.      deleted.  For example, `5,7d3' means delete lines 5-7 of file 1;
  391.      or, if changing file 2 into file 1, append lines 5-7 of file 1
  392.      after line 3 of file 2.
  393. File: diff.info,  Node: Example Normal,  Prev: Detailed Normal,  Up: Normal
  394. An Example of Normal Format
  395. ---------------------------
  396.    Here is the output of the command `diff lao tzu' (*note Sample diff
  397. Input::., for the complete contents of the two files).  Notice that it
  398. shows only the lines that are different between the two files.
  399.      1,2d0
  400.      < The Way that can be told of is not the eternal Way;
  401.      < The name that can be named is not the eternal name.
  402.      4c2,3
  403.      < The Named is the mother of all things.
  404.      ---
  405.      > The named is the mother of all things.
  406.      >
  407.      11a11,13
  408.      > They both may be called deep and profound.
  409.      > Deeper and more profound,
  410.      > The door of all subtleties!
  411. File: diff.info,  Node: Context,  Next: Side by Side,  Prev: Normal,  Up: Output Formats
  412. Showing Differences in Their Context
  413. ====================================
  414.    Usually, when you are looking at the differences between files, you
  415. will also want to see the parts of the files near the lines that
  416. differ, to help you understand exactly what has changed.  These nearby
  417. parts of the files are called the "context".
  418.    GNU `diff' provides two output formats that show context around the
  419. differing lines: "context format" and "unified format".  It can
  420. optionally show in which function or section of the file the differing
  421. lines are found.
  422.    If you are distributing new versions of files to other people in the
  423. form of `diff' output, you should use one of the output formats that
  424. show context so that they can apply the diffs even if they have made
  425. small changes of their own to the files.  `patch' can apply the diffs
  426. in this case by searching in the files for the lines of context around
  427. the differing lines; if those lines are actually a few lines away from
  428. where the diff says they are, `patch' can adjust the line numbers
  429. accordingly and still apply the diff correctly.  *Note Imperfect::, for
  430. more information on using `patch' to apply imperfect diffs.
  431. * Menu:
  432. * Context Format::    An output format that shows surrounding lines.
  433. * Unified Format::    A more compact output format that shows context.
  434. * Sections::        Showing which sections of the files differences are in.
  435. * Alternate Names::    Showing alternate file names in context headers.
  436. File: diff.info,  Node: Context Format,  Next: Unified Format,  Up: Context
  437. Context Format
  438. --------------
  439.    The context output format shows several lines of context around the
  440. lines that differ.  It is the standard format for distributing updates
  441. to source code.
  442.    To select this output format, use the `-C LINES',
  443. `--context[=LINES]', or `-c' option.  The argument LINES that some of
  444. these options take is the number of lines of context to show.  If you
  445. do not specify LINES, it defaults to three.  For proper operation,
  446. `patch' typically needs at least two lines of context.
  447. * Menu:
  448. * Detailed Context::    A detailed description of the context output format.
  449. * Example Context::    Sample output in context format.
  450. * Less Context::    Another sample with less context.
  451. File: diff.info,  Node: Detailed Context,  Next: Example Context,  Up: Context Format
  452. Detailed Description of Context Format
  453. ......................................
  454.    The context output format starts with a two-line header, which looks
  455. like this:
  456.      *** FROM-FILE FROM-FILE-MODIFICATION-TIME
  457.      --- TO-FILE TO-FILE-MODIFICATION TIME
  458. You can change the header's content with the `-L LABEL' or
  459. `--label=LABEL' option; see *Note Alternate Names::.
  460.    Next come one or more hunks of differences; each hunk shows one area
  461. where the files differ.  Context format hunks look like this:
  462.      ***************
  463.      *** FROM-FILE-LINE-RANGE ****
  464.        FROM-FILE-LINE
  465.        FROM-FILE-LINE...
  466.      --- TO-FILE-LINE-RANGE ----
  467.        TO-FILE-LINE
  468.        TO-FILE-LINE...
  469.    The lines of context around the lines that differ start with two
  470. space characters.  The lines that differ between the two files start
  471. with one of the following indicator characters, followed by a space
  472. character:
  473.      A line that is part of a group of one or more lines that changed
  474.      between the two files.  There is a corresponding group of lines
  475.      marked with `!' in the part of this hunk for the other file.
  476.      An "inserted" line in the second file that corresponds to nothing
  477.      in the first file.
  478.      A "deleted" line in the first file that corresponds to nothing in
  479.      the second file.
  480.    If all of the changes in a hunk are insertions, the lines of
  481. FROM-FILE are omitted.  If all of the changes are deletions, the lines
  482. of TO-FILE are omitted.
  483. File: diff.info,  Node: Example Context,  Next: Less Context,  Prev: Detailed Context,  Up: Context Format
  484. An Example of Context Format
  485. ............................
  486.    Here is the output of `diff -c lao tzu' (*note Sample diff Input::.,
  487. for the complete contents of the two files).  Notice that up to three
  488. lines that are not different are shown around each line that is
  489. different; they are the context lines.  Also notice that the first two
  490. hunks have run together, because their contents overlap.
  491.      *** lao    Sat Jan 26 23:30:39 1991
  492.      --- tzu    Sat Jan 26 23:30:50 1991
  493.      ***************
  494.      *** 1,7 ****
  495.      - The Way that can be told of is not the eternal Way;
  496.      - The name that can be named is not the eternal name.
  497.        The Nameless is the origin of Heaven and Earth;
  498.      ! The Named is the mother of all things.
  499.        Therefore let there always be non-being,
  500.          so we may see their subtlety,
  501.        And let there always be being,
  502.      --- 1,6 ----
  503.        The Nameless is the origin of Heaven and Earth;
  504.      ! The named is the mother of all things.
  505.      !
  506.        Therefore let there always be non-being,
  507.          so we may see their subtlety,
  508.        And let there always be being,
  509.      ***************
  510.      *** 9,11 ****
  511.      --- 8,13 ----
  512.        The two are the same,
  513.        But after they are produced,
  514.          they have different names.
  515.      + They both may be called deep and profound.
  516.      + Deeper and more profound,
  517.      + The door of all subtleties!
  518. File: diff.info,  Node: Less Context,  Prev: Example Context,  Up: Context Format
  519. An Example of Context Format with Less Context
  520. ..............................................
  521.    Here is the output of `diff --context=1 lao tzu' (*note Sample diff
  522. Input::., for the complete contents of the two files).  Notice that at
  523. most one context line is reported here.
  524.      *** lao    Sat Jan 26 23:30:39 1991
  525.      --- tzu    Sat Jan 26 23:30:50 1991
  526.      ***************
  527.      *** 1,5 ****
  528.      - The Way that can be told of is not the eternal Way;
  529.      - The name that can be named is not the eternal name.
  530.        The Nameless is the origin of Heaven and Earth;
  531.      ! The Named is the mother of all things.
  532.        Therefore let there always be non-being,
  533.      --- 1,4 ----
  534.        The Nameless is the origin of Heaven and Earth;
  535.      ! The named is the mother of all things.
  536.      !
  537.        Therefore let there always be non-being,
  538.      ***************
  539.      *** 11 ****
  540.      --- 10,13 ----
  541.          they have different names.
  542.      + They both may be called deep and profound.
  543.      + Deeper and more profound,
  544.      + The door of all subtleties!
  545. File: diff.info,  Node: Unified Format,  Next: Sections,  Prev: Context Format,  Up: Context
  546. Unified Format
  547. --------------
  548.    The unified output format is a variation on the context format that
  549. is more compact because it omits redundant context lines.  To select
  550. this output format, use the `-U LINES', `--unified[=LINES]', or `-u'
  551. option.  The argument LINES is the number of lines of context to show.
  552. When it is not given, it defaults to three.
  553.    At present, only GNU `diff' can produce this format and only GNU
  554. `patch' can automatically apply diffs in this format.  For proper
  555. operation, `patch' typically needs at least two lines of context.
  556. * Menu:
  557. * Detailed Unified::    A detailed description of unified format.
  558. * Example Unified::    Sample output in unified format.
  559. File: diff.info,  Node: Detailed Unified,  Next: Example Unified,  Up: Unified Format
  560. Detailed Description of Unified Format
  561. ......................................
  562.    The unified output format starts with a two-line header, which looks
  563. like this:
  564.      --- FROM-FILE FROM-FILE-MODIFICATION-TIME
  565.      +++ TO-FILE TO-FILE-MODIFICATION-TIME
  566. You can change the header's content with the `-L LABEL' or
  567. `--label=LABEL' option; see *Note Alternate Names::.
  568.    Next come one or more hunks of differences; each hunk shows one area
  569. where the files differ.  Unified format hunks look like this:
  570.      @@ FROM-FILE-RANGE TO-FILE-RANGE @@
  571.       LINE-FROM-EITHER-FILE
  572.       LINE-FROM-EITHER-FILE...
  573.    The lines common to both files begin with a space character.  The
  574. lines that actually differ between the two files have one of the
  575. following indicator characters in the left column:
  576.      A line was added here to the first file.
  577.      A line was removed here from the first file.
  578. File: diff.info,  Node: Example Unified,  Prev: Detailed Unified,  Up: Unified Format
  579. An Example of Unified Format
  580. ............................
  581.    Here is the output of the command `diff -u lao tzu' (*note Sample
  582. diff Input::., for the complete contents of the two files):
  583.      --- lao    Sat Jan 26 23:30:39 1991
  584.      +++ tzu    Sat Jan 26 23:30:50 1991
  585.      @@ -1,7 +1,6 @@
  586.      -The Way that can be told of is not the eternal Way;
  587.      -The name that can be named is not the eternal name.
  588.       The Nameless is the origin of Heaven and Earth;
  589.      -The Named is the mother of all things.
  590.      +The named is the mother of all things.
  591.      +
  592.       Therefore let there always be non-being,
  593.         so we may see their subtlety,
  594.       And let there always be being,
  595.      @@ -9,3 +8,6 @@
  596.       The two are the same,
  597.       But after they are produced,
  598.         they have different names.
  599.      +They both may be called deep and profound.
  600.      +Deeper and more profound,
  601.      +The door of all subtleties!
  602. File: diff.info,  Node: Sections,  Next: Alternate Names,  Prev: Unified Format,  Up: Context
  603. Showing Which Sections Differences Are in
  604. -----------------------------------------
  605.    Sometimes you might want to know which part of the files each change
  606. falls in.  If the files are source code, this could mean which function
  607. was changed.  If the files are documents, it could mean which chapter or
  608. appendix was changed.  GNU `diff' can show this by displaying the
  609. nearest section heading line that precedes the differing lines.  Which
  610. lines are "section headings" is determined by a regular expression.
  611. * Menu:
  612. * Specified Headings::    Showing headings that match regular expressions.
  613. * C Function Headings::    Showing headings of C functions.
  614. File: diff.info,  Node: Specified Headings,  Next: C Function Headings,  Up: Sections
  615. Showing Lines That Match Regular Expressions
  616. ............................................
  617.    To show in which sections differences occur for files that are not
  618. source code for C or similar languages, use the `-F REGEXP' or
  619. `--show-function-line=REGEXP' option.  `diff' considers lines that
  620. match the argument REGEXP to be the beginning of a section of the file.
  621. Here are suggested regular expressions for some common languages:
  622. `^[A-Za-z_]'
  623.      C, C++, Prolog
  624.      Lisp
  625. `^@\(chapter\|appendix\|unnumbered\|chapheading\)'
  626.      Texinfo
  627.    This option does not automatically select an output format; in order
  628. to use it, you must select the context format (*note Context Format::.)
  629. or unified format (*note Unified Format::.).  In other output formats it
  630. has no effect.
  631.    The `-F' and `--show-function-line' options find the nearest
  632. unchanged line that precedes each hunk of differences and matches the
  633. given regular expression.  Then they add that line to the end of the
  634. line of asterisks in the context format, or to the `@@' line in unified
  635. format.  If no matching line exists, they leave the output for that
  636. hunk unchanged.  If that line is more than 40 characters long, they
  637. output only the first 40 characters.  You can specify more than one
  638. regular expression for such lines; `diff' tries to match each line
  639. against each regular expression, starting with the last one given.  This
  640. means that you can use `-p' and `-F' together, if you wish.
  641. File: diff.info,  Node: C Function Headings,  Prev: Specified Headings,  Up: Sections
  642. Showing C Function Headings
  643. ...........................
  644.    To show in which functions differences occur for C and similar
  645. languages, you can use the `-p' or `--show-c-function' option.  This
  646. option automatically selects the context output format (*note Context
  647. Format::.), with the default number of lines of context.  You can
  648. override that number with `-C LINES' later in the command line.  You
  649. can override both the format and the number with `-U LINES' later in
  650. the command line.
  651.    The `-p' and `--show-c-function' options are equivalent to `-c
  652. -F'^[_a-zA-Z$]'' (*note Specified Headings::.).  GNU `diff' provides
  653. them for the sake of convenience.
  654. File: diff.info,  Node: Alternate Names,  Prev: Sections,  Up: Context
  655. Showing Alternate File Names
  656. ----------------------------
  657.    If you are comparing two files that have meaningless or uninformative
  658. names, you might want `diff' to show alternate names in the header of
  659. the context and unified output formats.  To do this, use the `-L LABEL'
  660. or `--label=LABEL' option.  The first time you give this option, its
  661. argument replaces the name and date of the first file in the header;
  662. the second time, its argument replaces the name and date of the second
  663. file.  If you give this option more than twice, `diff' reports an
  664. error.  The `-L' option does not affect the file names in the `pr'
  665. header when the `-l' or `--paginate' option is used (*note
  666. Pagination::.).
  667.    Here are the first two lines of the output from `diff -C2 -Loriginal
  668. -Lmodified lao tzu':
  669.      *** original
  670.      --- modified
  671. File: diff.info,  Node: Side by Side,  Next: Scripts,  Prev: Context,  Up: Output Formats
  672. Showing Differences Side by Side
  673. ================================
  674.    `diff' can produce a side by side difference listing of two files.
  675. The files are listed in two columns with a gutter between them.  The
  676. gutter contains one of the following markers:
  677. white space
  678.      The corresponding lines are in common.  That is, either the lines
  679.      are identical, or the difference is ignored because of one of the
  680.      `--ignore' options (*note White Space::.).
  681.      The corresponding lines differ, and they are either both complete
  682.      or both incomplete.
  683.      The files differ and only the first file contains the line.
  684.      The files differ and only the second file contains the line.
  685.      Only the first file contains the line, but the difference is
  686.      ignored.
  687.      Only the second file contains the line, but the difference is
  688.      ignored.
  689.      The corresponding lines differ, and only the first line is
  690.      incomplete.
  691.      The corresponding lines differ, and only the second line is
  692.      incomplete.
  693.    Normally, an output line is incomplete if and only if the lines that
  694. it contains are incomplete; *Note Incomplete Lines::.  However, when an
  695. output line represents two differing lines, one might be incomplete
  696. while the other is not.  In this case, the output line is complete, but
  697. its the gutter is marked `\' if the first line is incomplete, `/' if
  698. the second line is.
  699.    Side by side format is sometimes easiest to read, but it has
  700. limitations.  It generates much wider output than usual, and truncates
  701. lines that are too long to fit.  Also, it relies on lining up output
  702. more heavily than usual, so its output looks particularly bad if you
  703. use varying width fonts, nonstandard tab stops, or nonprinting
  704. characters.
  705.    You can use the `sdiff' command to interactively merge side by side
  706. differences.  *Note Interactive Merging::, for more information on
  707. merging files.
  708. * Menu:
  709. * Side by Side Format::        Controlling side by side output format.
  710. * Example Side by Side::    Sample side by side output.
  711. File: diff.info,  Node: Side by Side Format,  Next: Example Side by Side,  Up: Side by Side
  712. Controlling Side by Side Format
  713. ===============================
  714.    The `-y' or `--side-by-side' option selects side by side format.
  715. Because side by side output lines contain two input lines, they are
  716. wider than usual.  They are normally 130 columns, which can fit onto a
  717. traditional printer line.  You can set the length of output lines with
  718. the `-W COLUMNS' or `--width=COLUMNS' option.  The output line is split
  719. into two halves of equal length, separated by a small gutter to mark
  720. differences; the right half is aligned to a tab stop so that tabs line
  721. up.  Input lines that are too long to fit in half of an output line are
  722. truncated for output.
  723.    The `--left-column' option prints only the left column of two common
  724. lines.  The `--suppress-common-lines' option suppresses common lines
  725. entirely.
  726. File: diff.info,  Node: Example Side by Side,  Prev: Side by Side Format,  Up: Side by Side
  727. An Example of Side by Side Format
  728. ---------------------------------
  729.    Here is the output of the command `diff -y -W 72 lao tzu' (*note
  730. Sample diff Input::., for the complete contents of the two files).
  731.      The Way that can be told of is n   <
  732.      The name that can be named is no   <
  733.      The Nameless is the origin of He        The Nameless is the origin of He
  734.      The Named is the mother of all t   |    The named is the mother of all t
  735.                                         >
  736.      Therefore let there always be no        Therefore let there always be no
  737.        so we may see their subtlety,           so we may see their subtlety,
  738.      And let there always be being,          And let there always be being,
  739.        so we may see their outcome.            so we may see their outcome.
  740.      The two are the same,                   The two are the same,
  741.      But after they are produced,            But after they are produced,
  742.        they have different names.              they have different names.
  743.                                         >    They both may be called deep and
  744.                                         >    Deeper and more profound,
  745.                                         >    The door of all subtleties!
  746. File: diff.info,  Node: Scripts,  Next: If-then-else,  Prev: Side by Side,  Up: Output Formats
  747. Making Edit Scripts
  748. ===================
  749.    Several output modes produce command scripts for editing FROM-FILE
  750. to produce TO-FILE.
  751. * Menu:
  752. * ed Scripts::        Using `diff' to produce commands for `ed'.
  753. * Forward ed::        Making forward `ed' scripts.
  754. * RCS::            A special `diff' output format used by RCS.
  755. File: diff.info,  Node: ed Scripts,  Next: Forward ed,  Up: Scripts
  756. `ed' Scripts
  757. ------------
  758.    `diff' can produce commands that direct the `ed' text editor to
  759. change the first file into the second file.  Long ago, this was the
  760. only output mode that was suitable for editing one file into another
  761. automatically; today, with `patch', it is almost obsolete.  Use the
  762. `-e' or `--ed' option to select this output format.
  763.    Like the normal format (*note Normal::.), this output format does not
  764. show any context; unlike the normal format, it does not include the
  765. information necessary to apply the diff in reverse (to produce the first
  766. file if all you have is the second file and the diff).
  767.    If the file `d' contains the output of `diff -e old new', then the
  768. command `(cat d && echo w) | ed - old' edits `old' to make it a copy of
  769. `new'.  More generally, if `d1', `d2', ..., `dN' contain the outputs of
  770. `diff -e old new1', `diff -e new1 new2', ..., `diff -e newN-1 newN',
  771. respectively, then the command `(cat d1 d2 ... dN && echo w) | ed -
  772. old' edits `old' to make it a copy of `newN'.
  773. * Menu:
  774. * Detailed ed::        A detailed description of `ed' format.
  775. * Example ed::        A sample `ed' script.
  776. File: diff.info,  Node: Detailed ed,  Next: Example ed,  Up: ed Scripts
  777. Detailed Description of `ed' Format
  778. ...................................
  779.    The `ed' output format consists of one or more hunks of differences.
  780. The changes closest to the ends of the files come first so that
  781. commands that change the number of lines do not affect how `ed'
  782. interprets line numbers in succeeding commands.  `ed' format hunks look
  783. like this:
  784.      CHANGE-COMMAND
  785.      TO-FILE-LINE
  786.      TO-FILE-LINE...
  787.      .
  788.    Because `ed' uses a single period on a line to indicate the end of
  789. input, GNU `diff' protects lines of changes that contain a single
  790. period on a line by writing two periods instead, then writing a
  791. subsequent `ed' command to change the two periods into one.  The `ed'
  792. format cannot represent an incomplete line, so if the second file ends
  793. in a changed incomplete line, `diff' reports an error and then pretends
  794. that a newline was appended.
  795.    There are three types of change commands.  Each consists of a line
  796. number or comma-separated range of lines in the first file and a single
  797. character indicating the kind of change to make.  All line numbers are
  798. the original line numbers in the file.  The types of change commands
  799.      Add text from the second file after line L in the first file.  For
  800.      example, `8a' means to add the following lines after line 8 of file
  801.      1.
  802.      Replace the lines in range R in the first file with the following
  803.      lines.  Like a combined add and delete, but more compact.  For
  804.      example, `5,7c' means change lines 5-7 of file 1 to read as the
  805.      text file 2.
  806.      Delete the lines in range R from the first file.  For example,
  807.      `5,7d' means delete lines 5-7 of file 1.
  808. File: diff.info,  Node: Example ed,  Prev: Detailed ed,  Up: ed Scripts
  809. Example `ed' Script
  810. ...................
  811.    Here is the output of `diff -e lao tzu' (*note Sample diff Input::.,
  812. for the complete contents of the two files):
  813.      11a
  814.      They both may be called deep and profound.
  815.      Deeper and more profound,
  816.      The door of all subtleties!
  817.      .
  818.      4c
  819.      The named is the mother of all things.
  820.      
  821.      .
  822.      1,2d
  823. File: diff.info,  Node: Forward ed,  Next: RCS,  Prev: ed Scripts,  Up: Scripts
  824. Forward `ed' Scripts
  825. --------------------
  826.    `diff' can produce output that is like an `ed' script, but with
  827. hunks in forward (front to back) order.  The format of the commands is
  828. also changed slightly: command characters precede the lines they
  829. modify, spaces separate line numbers in ranges, and no attempt is made
  830. to disambiguate hunk lines consisting of a single period.  Like `ed'
  831. format, forward `ed' format cannot represent incomplete lines.
  832.    Forward `ed' format is not very useful, because neither `ed' nor
  833. `patch' can apply diffs in this format.  It exists mainly for
  834. compatibility with older versions of `diff'.  Use the `-f' or
  835. `--forward-ed' option to select it.
  836. File: diff.info,  Node: RCS,  Prev: Forward ed,  Up: Scripts
  837. RCS Scripts
  838. -----------
  839.    The RCS output format is designed specifically for use by the
  840. Revision Control System, which is a set of free programs used for
  841. organizing different versions and systems of files.  Use the `-n' or
  842. `--rcs' option to select this output format.  It is like the forward
  843. `ed' format (*note Forward ed::.), but it can represent arbitrary
  844. changes to the contents of a file because it avoids the forward `ed'
  845. format's problems with lines consisting of a single period and with
  846. incomplete lines.  Instead of ending text sections with a line
  847. consisting of a single period, each command specifies the number of
  848. lines it affects; a combination of the `a' and `d' commands are used
  849. instead of `c'.  Also, if the second file ends in a changed incomplete
  850. line, then the output also ends in an incomplete line.
  851.    Here is the output of `diff -n lao tzu' (*note Sample diff Input::.,
  852. for the complete contents of the two files):
  853.      d1 2
  854.      d4 1
  855.      a4 2
  856.      The named is the mother of all things.
  857.      
  858.      a11 3
  859.      They both may be called deep and profound.
  860.      Deeper and more profound,
  861.      The door of all subtleties!
  862. File: diff.info,  Node: If-then-else,  Prev: Scripts,  Up: Output Formats
  863. Merging Files with If-then-else
  864. ===============================
  865.    You can use `diff' to merge two files of C source code.  The output
  866. of `diff' in this format contains all the lines of both files.  Lines
  867. common to both files are output just once; the differing parts are
  868. separated by the C preprocessor directives `#ifdef NAME' or `#ifndef
  869. NAME', `#else', and `#endif'.  When compiling the output, you select
  870. which version to use by either defining or leaving undefined the macro
  871. NAME.
  872.    To merge two files, use `diff' with the `-D NAME' or `--ifdef=NAME'
  873. option.  The argument NAME is the C preprocessor identifier to use in
  874. the `#ifdef' and `#ifndef' directives.
  875.    For example, if you change an instance of `wait (&s)' to `waitpid
  876. (-1, &s, 0)' and then merge the old and new files with the
  877. `--ifdef=HAVE_WAITPID' option, then the affected part of your code
  878. might look like this:
  879.          do {
  880.      #ifndef HAVE_WAITPID
  881.              if ((w = wait (&s)) < 0  &&  errno != EINTR)
  882.      #else /* HAVE_WAITPID */
  883.              if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
  884.      #endif /* HAVE_WAITPID */
  885.                  return w;
  886.          } while (w != child);
  887.    You can specify formats for languages other than C by using line
  888. group formats and line formats, as described in the next sections.
  889. * Menu:
  890. * Line Group Formats::        Formats for general if-then-else line groups.
  891. * Line Formats::        Formats for each line in a line group.
  892. * Detailed If-then-else::    A detailed description of if-then-else format.
  893. * Example If-then-else::    Sample if-then-else format output.
  894. File: diff.info,  Node: Line Group Formats,  Next: Line Formats,  Up: If-then-else
  895. Line Group Formats
  896. ------------------
  897.    Line group formats let you specify formats suitable for many
  898. applications that allow if-then-else input, including programming
  899. languages and text formatting languages.  A line group format specifies
  900. the output format for a contiguous group of similar lines.
  901.    For example, the following command compares the TeX files `old' and
  902. `new', and outputs a merged file in which old regions are surrounded by
  903. `\begin{em}'-`\end{em}' lines, and new regions are surrounded by
  904. `\begin{bf}'-`\end{bf}' lines.
  905.      diff \
  906.         --old-group-format='\begin{em}
  907.      %<\end{em}
  908.      ' \
  909.         --new-group-format='\begin{bf}
  910.      %>\end{bf}
  911.      ' \
  912.         old new
  913.    The following command is equivalent to the above example, but it is a
  914. little more verbose, because it spells out the default line group
  915. formats.
  916.      diff \
  917.         --old-group-format='\begin{em}
  918.      %<\end{em}
  919.      ' \
  920.         --new-group-format='\begin{bf}
  921.      %>\end{bf}
  922.      ' \
  923.         --unchanged-group-format='%=' \
  924.         --changed-group-format='\begin{em}
  925.      %<\end{em}
  926.      \begin{bf}
  927.      %>\end{bf}
  928.      ' \
  929.         old new
  930.    Here is a more advanced example, which outputs a diff listing with
  931. headers containing line numbers in a "plain English" style.
  932.      diff \
  933.         --unchanged-group-format='' \
  934.         --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
  935.      %<' \
  936.         --new-group-format='-------- %dN line%(N=1?:s) added after %de:
  937.      %>' \
  938.         --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
  939.      %<-------- to:
  940.      %>' \
  941.         old new
  942.    To specify a line group format, use `diff' with one of the options
  943. listed below.  You can specify up to four line group formats, one for
  944. each kind of line group.  You should quote FORMAT, because it typically
  945. contains shell metacharacters.
  946. `--old-group-format=FORMAT'
  947.      These line groups are hunks containing only lines from the first
  948.      file.  The default old group format is the same as the changed
  949.      group format if it is specified; otherwise it is a format that
  950.      outputs the line group as-is.
  951. `--new-group-format=FORMAT'
  952.      These line groups are hunks containing only lines from the second
  953.      file.  The default new group format is same as the the changed
  954.      group format if it is specified; otherwise it is a format that
  955.      outputs the line group as-is.
  956. `--changed-group-format=FORMAT'
  957.      These line groups are hunks containing lines from both files.  The
  958.      default changed group format is the concatenation of the old and
  959.      new group formats.
  960. `--unchanged-group-format=FORMAT'
  961.      These line groups contain lines common to both files.  The default
  962.      unchanged group format is a format that outputs the line group
  963.      as-is.
  964.    In a line group format, ordinary characters represent themselves;
  965. conversion specifications start with `%' and have one of the following
  966. forms.
  967.      stands for the lines from the first file, including the trailing
  968.      newline.  Each line is formatted according to the old line format
  969.      (*note Line Formats::.).
  970.      stands for the lines from the second file, including the trailing
  971.      newline.  Each line is formatted according to the new line format.
  972.      stands for the lines common to both files, including the trailing
  973.      newline.  Each line is formatted according to the unchanged line
  974.      format.
  975.      stands for `%'.
  976. `%c'C''
  977.      where C is a single character, stands for C.  C may not be a
  978.      backslash or an apostrophe.  For example, `%c':'' stands for a
  979.      colon, even inside the then-part of an if-then-else format, which
  980.      a colon would normally terminate.
  981. `%c'\O''
  982.      where O is a string of 1, 2, or 3 octal digits, stands for the
  983.      character with octal code O.  For example, `%c'\0'' stands for a
  984.      null character.
  985.      where F is a `printf' conversion specification and N is one of the
  986.      following letters, stands for N's value formatted with F.
  987.     `e'
  988.           The line number of the line just before the group in the old
  989.           file.
  990.     `f'
  991.           The line number of the first line in the group in the old
  992.           file; equals E + 1.
  993.     `l'
  994.           The line number of the last line in the group in the old file.
  995.     `m'
  996.           The line number of the line just after the group in the old
  997.           file; equals L + 1.
  998.     `n'
  999.           The number of lines in the group in the old file; equals L -
  1000.           F + 1.
  1001.     `E, F, L, M, N'
  1002.           Likewise, for lines in the new file.
  1003.      The `printf' conversion specification can be `%d', `%o', `%x', or
  1004.      `%X', specifying decimal, octal, lower case hexadecimal, or upper
  1005.      case hexadecimal output respectively.  After the `%' the following
  1006.      options can appear in sequence: a `-' specifying
  1007.      left-justification; an integer specifying the minimum field width;
  1008.      and a period followed by an optional integer specifying the
  1009.      minimum number of digits.  For example, `%5dN' prints the number
  1010.      of new lines in the group in a field of width 5 characters, using
  1011.      the `printf' format `"%5d"'.
  1012. `(A=B?T:E)'
  1013.      If A equals B then T else E.  A and B are each either a decimal
  1014.      constant or a single letter interpreted as above.  This format
  1015.      spec is equivalent to T if A's value equals B's; otherwise it is
  1016.      equivalent to E.
  1017.      For example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no
  1018.      lines' if N (the number of lines in the group in the the new file)
  1019.      is 0, to `1 line' if N is 1, and to `%dN lines' otherwise.
  1020. File: diff.info,  Node: Line Formats,  Next: Detailed If-then-else,  Prev: Line Group Formats,  Up: If-then-else
  1021. Line Formats
  1022. ------------
  1023.    Line formats control how each line taken from an input file is
  1024. output as part of a line group in if-then-else format.
  1025.    For example, the following command outputs text with a one-column
  1026. change indicator to the left of the text.  The first column of output
  1027. is `-' for deleted lines, `|' for added lines, and a space for
  1028. unchanged lines.  The formats contain newline characters where newlines
  1029. are desired on output.
  1030.      diff \
  1031.         --old-line-format='-%l
  1032.      ' \
  1033.         --new-line-format='|%l
  1034.      ' \
  1035.         --unchanged-line-format=' %l
  1036.      ' \
  1037.         old new
  1038.    To specify a line format, use one of the following options.  You
  1039. should quote FORMAT, since it often contains shell metacharacters.
  1040. `--old-line-format=FORMAT'
  1041.      formats lines just from the first file.
  1042. `--new-line-format=FORMAT'
  1043.      formats lines just from the second file.
  1044. `--unchanged-line-format=FORMAT'
  1045.      formats lines common to both files.
  1046. `--line-format=FORMAT'
  1047.      formats all lines; in effect, it sets all three above options
  1048.      simultaneously.
  1049.    In a line format, ordinary characters represent themselves;
  1050. conversion specifications start with `%' and have one of the following
  1051. forms.
  1052.      stands for the the contents of the line, not counting its trailing
  1053.      newline (if any).  This format ignores whether the line is
  1054.      incomplete; *Note Incomplete Lines::.
  1055.      stands for the the contents of the line, including its trailing
  1056.      newline (if any).  If a line is incomplete, this format preserves
  1057.      its incompleteness.
  1058.      stands for `%'.
  1059. `%c'C''
  1060.      where C is a single character, stands for C.  C may not be a
  1061.      backslash or an apostrophe.  For example, `%c':'' stands for a
  1062.      colon.
  1063. `%c'\O''
  1064.      where O is a string of 1, 2, or 3 octal digits, stands for the
  1065.      character with octal code O.  For example, `%c'\0'' stands for a
  1066.      null character.
  1067.      where F is a `printf' conversion specification, stands for the
  1068.      line number formatted with F.  For example, `%.5dn' prints the
  1069.      line number using the `printf' format `"%.5d"'.  *Note Line Group
  1070.      Formats::, for more about printf conversion specifications.
  1071.    The default line format is `%l' followed by a newline character.
  1072.    If the input contains tab characters and it is important that they
  1073. line up on output, you should ensure that `%l' or `%L' in a line format
  1074. is just after a tab stop (e.g. by preceding `%l' or `%L' with a tab
  1075. character), or you should use the `-t' or `--expand-tabs' option.
  1076.    Taken together, the line and line group formats let you specify many
  1077. different formats.  For example, the following command uses a format
  1078. similar to `diff''s normal format.  You can tailor this command to get
  1079. fine control over `diff''s output.
  1080.      diff \
  1081.         --old-line-format='< %l
  1082.      ' \
  1083.         --new-line-format='> %l
  1084.      ' \
  1085.         --old-group-format='%df%(f=l?:,%dl)d%dE
  1086.      %<' \
  1087.         --new-group-format='%dea%dF%(F=L?:,%dL)
  1088.      %>' \
  1089.         --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
  1090.      %<---
  1091.      %>' \
  1092.         --unchanged-group-format='' \
  1093.         old new
  1094. File: diff.info,  Node: Detailed If-then-else,  Next: Example If-then-else,  Prev: Line Formats,  Up: If-then-else
  1095. Detailed Description of If-then-else Format
  1096. -------------------------------------------
  1097.    For lines common to both files, `diff' uses the unchanged line group
  1098. format.  For each hunk of differences in the merged output format, if
  1099. the hunk contains only lines from the first file, `diff' uses the old
  1100. line group format; if the hunk contains only lines from the second
  1101. file, `diff' uses the new group format; otherwise, `diff' uses the
  1102. changed group format.
  1103.    The old, new, and unchanged line formats specify the output format of
  1104. lines from the first file, lines from the second file, and lines common
  1105. to both files, respectively.
  1106.    The option `--ifdef=NAME' is equivalent to the following sequence of
  1107. options using shell syntax:
  1108.      --old-group-format='#ifndef NAME
  1109.      %<#endif /* not NAME */
  1110.      ' \
  1111.      --new-group-format='#ifdef NAME
  1112.      %>#endif /* NAME */
  1113.      ' \
  1114.      --unchanged-group-format='%=' \
  1115.      --changed-group-format='#ifndef NAME
  1116.      %<#else /* NAME */
  1117.      %>#endif /* NAME */
  1118.      '
  1119.    You should carefully check the `diff' output for proper nesting.
  1120. For example, when using the the `-D NAME' or `--ifdef=NAME' option, you
  1121. should check that if the differing lines contain any of the C
  1122. preprocessor directives `#ifdef', `#ifndef', `#else', `#elif', or
  1123. `#endif', they are nested properly and match.  If they don't, you must
  1124. make corrections manually.  It is a good idea to carefully check the
  1125. resulting code anyway to make sure that it really does what you want it
  1126. to; depending on how the input files were produced, the output might
  1127. contain duplicate or otherwise incorrect code.
  1128.    The `patch' `-D NAME' option behaves just like the `diff' `-D NAME'
  1129. option, except it operates on a file and a diff to produce a merged
  1130. file; *Note patch Options::.
  1131. File: diff.info,  Node: Example If-then-else,  Prev: Detailed If-then-else,  Up: If-then-else
  1132. An Example of If-then-else Format
  1133. ---------------------------------
  1134.    Here is the output of `diff -DTWO lao tzu' (*note Sample diff
  1135. Input::., for the complete contents of the two files):
  1136.      #ifndef TWO
  1137.      The Way that can be told of is not the eternal Way;
  1138.      The name that can be named is not the eternal name.
  1139.      #endif /* not TWO */
  1140.      The Nameless is the origin of Heaven and Earth;
  1141.      #ifndef TWO
  1142.      The Named is the mother of all things.
  1143.      #else /* TWO */
  1144.      The named is the mother of all things.
  1145.      
  1146.      #endif /* TWO */
  1147.      Therefore let there always be non-being,
  1148.        so we may see their subtlety,
  1149.      And let there always be being,
  1150.        so we may see their outcome.
  1151.      The two are the same,
  1152.      But after they are produced,
  1153.        they have different names.
  1154.      #ifdef TWO
  1155.      They both may be called deep and profound.
  1156.      Deeper and more profound,
  1157.      The door of all subtleties!
  1158.      #endif /* TWO */
  1159. File: diff.info,  Node: Comparing Directories,  Next: Adjusting Output,  Prev: Output Formats,  Up: Top
  1160. Comparing Directories
  1161. *********************
  1162.    You can use `diff' to compare some or all of the files in two
  1163. directory trees.  When both file name arguments to `diff' are
  1164. directories, it compares each file that is contained in both
  1165. directories, examining file names in alphabetical order.  Normally
  1166. `diff' is silent about pairs of files that contain no differences, but
  1167. if you use the `-s' or `--report-identical-files' option, it reports
  1168. pairs of identical files.  Normally `diff' reports subdirectories
  1169. common to both directories without comparing subdirectories' files, but
  1170. if you use the `-r' or `--recursive' option, it compares every
  1171. corresponding pair of files in the directory trees, as many levels deep
  1172. as they go.
  1173.    For file names that are in only one of the directories, `diff'
  1174. normally does not show the contents of the file that exists; it reports
  1175. only that the file exists in that directory and not in the other.  You
  1176. can make `diff' act as though the file existed but was empty in the
  1177. other directory, so that it outputs the entire contents of the file that
  1178. actually exists.  (It is output as either an insertion or a deletion,
  1179. depending on whether it is in the first or the second directory given.)
  1180. To do this, use the `-N' or `--new-file' option.
  1181.    If the older directory contains one or more large files that are not
  1182. in the newer directory, you can make the patch smaller by using the
  1183. `-P' or `--unidirectional-new-file' option instead of `-N'.  This
  1184. option is like `-N' except that it only inserts the contents of files
  1185. that appear in the second directory but not the first (that is, files
  1186. that were added).  At the top of the patch, write instructions for the
  1187. user applying the patch to remove the files that were deleted before
  1188. applying the patch.  *Note Making Patches::, for more discussion of
  1189. making patches for distribution.
  1190.    To ignore some files while comparing directories, use the `-x
  1191. PATTERN' or `--exclude=PATTERN' option.  This option ignores any files
  1192. or subdirectories whose base names match the shell pattern PATTERN.
  1193. Unlike in the shell, a period at the start of the base of a file name
  1194. matches a wildcard at the start of a pattern.  You should enclose
  1195. PATTERN in quotes so that the shell does not expand it.  For example,
  1196. the option `-x '*.[ao]'' ignores any file whose name ends with `.a' or
  1197. `.o'.
  1198.    This option accumulates if you specify it more than once.  For
  1199. example, using the options `-x 'RCS' -x '*,v'' ignores any file or
  1200. subdirectory whose base name is `RCS' or ends with `,v'.
  1201.    If you need to give this option many times, you can instead put the
  1202. patterns in a file, one pattern per line, and use the `-X FILE' or
  1203. `--exclude-from=FILE' option.
  1204.    If you have been comparing two directories and stopped partway
  1205. through, later you might want to continue where you left off.  You can
  1206. do this by using the `-S FILE' or `--starting-file=FILE' option.  This
  1207. compares only the file FILE and all alphabetically later files in the
  1208. topmost directory level.
  1209. File: diff.info,  Node: Adjusting Output,  Next: diff Performance,  Prev: Comparing Directories,  Up: Top
  1210. Making `diff' Output Prettier
  1211. *****************************
  1212.    `diff' provides several ways to adjust the appearance of its output.
  1213. These adjustments can be applied to any output format.
  1214. * Menu:
  1215. * Tabs::        Preserving the alignment of tabstops.
  1216. * Pagination::        Page numbering and timestamping `diff' output.
  1217. File: diff.info,  Node: Tabs,  Next: Pagination,  Up: Adjusting Output
  1218. Preserving Tabstop Alignment
  1219. ============================
  1220.    The lines of text in some of the `diff' output formats are preceded
  1221. by one or two characters that indicate whether the text is inserted,
  1222. deleted, or changed.  The addition of those characters can cause tabs to
  1223. move to the next tabstop, throwing off the alignment of columns in the
  1224. line.  GNU `diff' provides two ways to make tab-aligned columns line up
  1225. correctly.
  1226.    The first way is to have `diff' convert all tabs into the correct
  1227. number of spaces before outputting them; select this method with the
  1228. `-t' or `--expand-tabs' option.  `diff' assumes that tabstops are set
  1229. every 8 columns.  To use this form of output with `patch', you must
  1230. give `patch' the `-l' or `--ignore-white-space' option (*note Changed
  1231. White Space::., for more information).
  1232.    The other method for making tabs line up correctly is to add a tab
  1233. character instead of a space after the indicator character at the
  1234. beginning of the line.  This ensures that all following tab characters
  1235. are in the same position relative to tabstops that they were in the
  1236. original files, so that the output is aligned correctly.  Its
  1237. disadvantage is that it can make long lines too long to fit on one line
  1238. of the screen or the paper.  It also does not work with the unified
  1239. output format, which does not have a space character after the change
  1240. type indicator character.  Select this method with the `-T' or
  1241. `--initial-tab' option.
  1242. File: diff.info,  Node: Pagination,  Prev: Tabs,  Up: Adjusting Output
  1243. Paginating `diff' Output
  1244. ========================
  1245.    It can be convenient to have long output page-numbered and
  1246. time-stamped.  The `-l' and `--paginate' options do this by sending the
  1247. `diff' output through the `pr' program.  Here is what the page header
  1248. might look like for `diff -lc lao tzu':
  1249.      Mar 11 13:37 1991  diff -lc lao tzu Page 1
  1250. File: diff.info,  Node: diff Performance,  Next: Comparing Three Files,  Prev: Adjusting Output,  Up: Top
  1251. `diff' Performance Tradeoffs
  1252. ****************************
  1253.    GNU `diff' runs quite efficiently; however, in some circumstances
  1254. you can cause it to run faster or produce a more compact set of changes.
  1255. There are two ways that you can affect the performance of GNU `diff' by
  1256. changing the way it compares files.
  1257.    Performance has more than one dimension.  These options improve one
  1258. aspect of performance at the cost of another, or they improve
  1259. performance in some cases while hurting it in others.
  1260.    The way that GNU `diff' determines which lines have changed always
  1261. comes up with a near-minimal set of differences.  Usually it is good
  1262. enough for practical purposes.  If the `diff' output is large, you
  1263. might want `diff' to use a modified algorithm that sometimes produces a
  1264. smaller set of differences.  The `-d' or `--minimal' option does this;
  1265. however, it can also cause `diff' to run more slowly than usual, so it
  1266. is not the default behavior.
  1267.    When the files you are comparing are large and have small groups of
  1268. changes scattered throughout them, you can use the `-H' or
  1269. `--speed-large-files' option to make a different modification to the
  1270. algorithm that `diff' uses.  If the input files have a constant small
  1271. density of changes, this option speeds up the comparisons without
  1272. changing the output.  If not, `diff' might produce a larger set of
  1273. differences; however, the output will still be correct.
  1274.    Normally `diff' discards the prefix and suffix that is common to
  1275. both files before it attempts to find a minimal set of differences.
  1276. This makes `diff' run faster, but occasionally it may produce
  1277. non-minimal output.  The `--horizon-lines=LINES' option prevents `diff'
  1278. from discarding the last LINES lines of the prefix and the first LINES
  1279. lines of the suffix.  This gives `diff' further opportunities to find a
  1280. minimal output.
  1281. File: diff.info,  Node: Comparing Three Files,  Next: diff3 Merging,  Prev: diff Performance,  Up: Top
  1282. Comparing Three Files
  1283. *********************
  1284.    Use the program `diff3' to compare three files and show any
  1285. differences among them.  (`diff3' can also merge files; see *Note diff3
  1286. Merging::).
  1287.    The "normal" `diff3' output format shows each hunk of differences
  1288. without surrounding context.  Hunks are labeled depending on whether
  1289. they are two-way or three-way, and lines are annotated by their
  1290. location in the input files.
  1291.    *Note Invoking diff3::, for more information on how to run `diff3'.
  1292. * Menu:
  1293. * Sample diff3 Input::        Sample `diff3' input for examples.
  1294. * Detailed diff3 Normal::    A detailed description of normal output format.
  1295. * diff3 Hunks::            The format of normal output format.
  1296. * Example diff3 Normal::    Sample output in the normal format.
  1297. File: diff.info,  Node: Sample diff3 Input,  Next: Detailed diff3 Normal,  Up: Comparing Three Files
  1298. A Third Sample Input File
  1299. =========================
  1300.    Here is a third sample file that will be used in examples to
  1301. illustrate the output of `diff3' and how various options can change it.
  1302. The first two files are the same that we used for `diff' (*note Sample
  1303. diff Input::.).  This is the third sample file, called `tao':
  1304.      The Way that can be told of is not the eternal Way;
  1305.      The name that can be named is not the eternal name.
  1306.      The Nameless is the origin of Heaven and Earth;
  1307.      The named is the mother of all things.
  1308.      
  1309.      Therefore let there always be non-being,
  1310.        so we may see their subtlety,
  1311.      And let there always be being,
  1312.        so we may see their result.
  1313.      The two are the same,
  1314.      But after they are produced,
  1315.        they have different names.
  1316.      
  1317.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1318. File: diff.info,  Node: Detailed diff3 Normal,  Next: diff3 Hunks,  Prev: Sample diff3 Input,  Up: Comparing Three Files
  1319. Detailed Description of `diff3' Normal Format
  1320. =============================================
  1321.    Each hunk begins with a line marked `===='.  Three-way hunks have
  1322. plain `====' lines, and two-way hunks have `1', `2', or `3' appended to
  1323. specify which of the three input files differ in that hunk.  The hunks
  1324. contain copies of two or three sets of input lines each preceded by one
  1325. or two commands identifying where the lines came from.
  1326.    Normally, two spaces precede each copy of an input line to
  1327. distinguish it from the commands.  But with the `-T' or `--initial-tab'
  1328. option, `diff3' uses a tab instead of two spaces; this lines up tabs
  1329. correctly.  *Note Tabs::, for more information.
  1330.    Commands take the following forms:
  1331. `FILE:La'
  1332.      This hunk appears after line L of file FILE, and contains no lines
  1333.      in that file.  To edit this file to yield the other files, one
  1334.      must append hunk lines taken from the other files.  For example,
  1335.      `1:11a' means that the hunk follows line 11 in the first file and
  1336.      contains no lines from that file.
  1337. `FILE:Rc'
  1338.      This hunk contains the lines in the range R of file FILE.  The
  1339.      range R is a comma-separated pair of line numbers, or just one
  1340.      number if the range is a singleton.  To edit this file to yield the
  1341.      other files, one must change the specified lines to be the lines
  1342.      taken from the other files.  For example, `2:11,13c' means that
  1343.      the hunk contains lines 11 through 13 from the second file.
  1344.    If the last line in a set of input lines is incomplete (*note
  1345. Incomplete Lines::.), it is distinguished on output from a full line by
  1346. a following line that starts with `\'.
  1347. File: diff.info,  Node: diff3 Hunks,  Next: Example diff3 Normal,  Prev: Detailed diff3 Normal,  Up: Comparing Three Files
  1348. `diff3' Hunks
  1349. =============
  1350.    Groups of lines that differ in two or three of the input files are
  1351. called "diff3 hunks", by analogy with `diff' hunks (*note Hunks::.).
  1352. If all three input files differ in a `diff3' hunk, the hunk is called a
  1353. "three-way hunk"; if just two input files differ, it is a "two-way
  1354. hunk".
  1355.    As with `diff', several solutions are possible.  When comparing the
  1356. files `A', `B', and `C', `diff3' normally finds `diff3' hunks by
  1357. merging the two-way hunks output by the two commands `diff A B' and
  1358. `diff A C'.  This does not necessarily minimize the size of the output,
  1359. but exceptions should be rare.
  1360.    For example, suppose `F' contains the three lines `a', `b', `f', `G'
  1361. contains the lines `g', `b', `g', and `H' contains the lines `a', `b',
  1362. `h'.  `diff3 F G H' might output the following:
  1363.      ====2
  1364.      1:1c
  1365.      3:1c
  1366.        a
  1367.      2:1c
  1368.        g
  1369.      ====
  1370.      1:3c
  1371.        f
  1372.      2:3c
  1373.        g
  1374.      3:3c
  1375.        h
  1376. because it found a two-way hunk containing `a' in the first and third
  1377. files and `g' in the second file, then the single line `b' common to
  1378. all three files, then a three-way hunk containing the last line of each
  1379. file.
  1380. File: diff.info,  Node: Example diff3 Normal,  Prev: diff3 Hunks,  Up: Comparing Three Files
  1381. An Example of `diff3' Normal Format
  1382. ===================================
  1383.    Here is the output of the command `diff3 lao tzu tao' (*note Sample
  1384. diff3 Input::., for the complete contents of the files).  Notice that
  1385. it shows only the lines that are different among the three files.
  1386.      ====2
  1387.      1:1,2c
  1388.      3:1,2c
  1389.        The Way that can be told of is not the eternal Way;
  1390.        The name that can be named is not the eternal name.
  1391.      2:0a
  1392.      ====1
  1393.      1:4c
  1394.        The Named is the mother of all things.
  1395.      2:2,3c
  1396.      3:4,5c
  1397.        The named is the mother of all things.
  1398.      
  1399.      ====3
  1400.      1:8c
  1401.      2:7c
  1402.          so we may see their outcome.
  1403.      3:9c
  1404.          so we may see their result.
  1405.      ====
  1406.      1:11a
  1407.      2:11,13c
  1408.        They both may be called deep and profound.
  1409.        Deeper and more profound,
  1410.        The door of all subtleties!
  1411.      3:13,14c
  1412.      
  1413.          -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1414. File: diff.info,  Node: diff3 Merging,  Next: Interactive Merging,  Prev: Comparing Three Files,  Up: Top
  1415. Merging From a Common Ancestor
  1416. ******************************
  1417.    When two people have made changes to copies of the same file,
  1418. `diff3' can produce a merged output that contains both sets of changes
  1419. together with warnings about conflicts.
  1420.    One might imagine programs with names like `diff4' and `diff5' to
  1421. compare more than three files simultaneously, but in practice the need
  1422. rarely arises.  You can use `diff3' to merge three or more sets of
  1423. changes to a file by merging two change sets at a time.
  1424.    `diff3' can incorporate changes from two modified versions into a
  1425. common preceding version.  This lets you merge the sets of changes
  1426. represented by the two newer files.  Specify the common ancestor version
  1427. as the second argument and the two newer versions as the first and third
  1428. arguments, like this:
  1429.      diff3 MINE OLDER YOURS
  1430. You can remember the order of the arguments by noting that they are in
  1431. alphabetical order.
  1432.    You can think of this as subtracting OLDER from YOURS and adding the
  1433. result to MINE, or as merging into MINE the changes that would turn
  1434. OLDER into YOURS.  This merging is well-defined as long as MINE and
  1435. OLDER match in the neighborhood of each such change.  This fails to be
  1436. true when all three input files differ or when only OLDER differs; we
  1437. call this a "conflict".  When all three input files differ, we call the
  1438. conflict an "overlap".
  1439.    `diff3' gives you several ways to handle overlaps and conflicts.
  1440. You can omit overlaps or conflicts, or select only overlaps, or mark
  1441. conflicts with special `<<<<<<<' and `>>>>>>>' lines.
  1442.    `diff3' can output the merge results as an `ed' script that that can
  1443. be applied to the first file to yield the merged output.  However, it
  1444. is usually better to have `diff3' generate the merged output directly;
  1445. this bypasses some problems with `ed'.
  1446. * Menu:
  1447. * Which Changes::        Selecting changes to incorporate.
  1448. * Marking Conflicts::        Marking conflicts.
  1449. * Bypassing ed::        Generating merged output directly.
  1450. * Merging Incomplete Lines::    How `diff3' merges incomplete lines.
  1451. * Saving the Changed File::    Emulating System V behavior.
  1452. File: diff.info,  Node: Which Changes,  Next: Marking Conflicts,  Up: diff3 Merging
  1453. Selecting Which Changes to Incorporate
  1454. ======================================
  1455.    You can select all unmerged changes from OLDER to YOURS for merging
  1456. into MINE with the `-e' or `--ed' option.  You can select only the
  1457. nonoverlapping unmerged changes with `-3' or `--easy-only', and you can
  1458. select only the overlapping changes with `-x' or `--overlap-only'.
  1459.    The `-e', `-3' and `-x' options select only "unmerged changes", i.e.
  1460. changes where MINE and YOURS differ; they ignore changes from OLDER to
  1461. YOURS where MINE and YOURS are identical, because they assume that such
  1462. changes have already been merged.  If this assumption is not a safe
  1463. one, you can use the `-A' or `--show-all' option (*note Marking
  1464. Conflicts::.).
  1465.    Here is the output of the command `diff3' with each of these three
  1466. options (*note Sample diff3 Input::., for the complete contents of the
  1467. files).  Notice that `-e' outputs the union of the disjoint sets of
  1468. changes output by `-3' and `-x'.
  1469.    Output of `diff3 -e lao tzu tao':
  1470.      11a
  1471.      
  1472.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1473.      .
  1474.      8c
  1475.        so we may see their result.
  1476.      .
  1477.    Output of `diff3 -3 lao tzu tao':
  1478.      8c
  1479.        so we may see their result.
  1480.      .
  1481.    Output of `diff3 -x lao tzu tao':
  1482.      11a
  1483.      
  1484.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1485.      .
  1486. File: diff.info,  Node: Marking Conflicts,  Next: Bypassing ed,  Prev: Which Changes,  Up: diff3 Merging
  1487. Marking Conflicts
  1488. =================
  1489.    `diff3' can mark conflicts in the merged output by bracketing them
  1490. with special marker lines.  A conflict that comes from two files A and
  1491. B is marked as follows:
  1492.      <<<<<<< A
  1493.      lines from A
  1494.      =======
  1495.      lines from B
  1496.      >>>>>>> B
  1497.    A conflict that comes from three files A, B and C is marked as
  1498. follows:
  1499.      <<<<<<< A
  1500.      lines from A
  1501.      ||||||| B
  1502.      lines from B
  1503.      =======
  1504.      lines from C
  1505.      >>>>>>> C
  1506.    The `-A' or `--show-all' option acts like the `-e' option, except
  1507. that it brackets conflicts, and it outputs all changes from OLDER to
  1508. YOURS, not just the unmerged changes.  Thus, given the sample input
  1509. files (*note Sample diff3 Input::.), `diff3 -A lao tzu tao' puts
  1510. brackets around the conflict where only `tzu' differs:
  1511.      <<<<<<< tzu
  1512.      =======
  1513.      The Way that can be told of is not the eternal Way;
  1514.      The name that can be named is not the eternal name.
  1515.      >>>>>>> tao
  1516.    And it outputs the three-way conflict as follows:
  1517.      <<<<<<< lao
  1518.      ||||||| tzu
  1519.      They both may be called deep and profound.
  1520.      Deeper and more profound,
  1521.      The door of all subtleties!
  1522.      =======
  1523.      
  1524.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1525.      >>>>>>> tao
  1526.    The `-E' or `--show-overlap' option outputs less information than
  1527. the `-A' or `--show-all' option, because it outputs only unmerged
  1528. changes, and it never outputs the contents of the second file.  Thus
  1529. the `-E' option acts like the `-e' option, except that it brackets the
  1530. first and third files from three-way overlapping changes.  Similarly,
  1531. `-X' acts like `-x', except it brackets all its (necessarily
  1532. overlapping) changes.  For example, for the three-way overlapping
  1533. change above, the `-E' and `-X' options output the following:
  1534.      <<<<<<< lao
  1535.      =======
  1536.      
  1537.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1538.      >>>>>>> tao
  1539.    If you are comparing files that have meaningless or uninformative
  1540. names, you can use the `-L LABEL' or `--label=LABEL' option to show
  1541. alternate names in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets.
  1542. This option can be given up to three times, once for each input file.
  1543. Thus `diff3 -A -L X -L Y -L Z A B C' acts like `diff3 -A A B C', except
  1544. that the output looks like it came from files named `X', `Y' and `Z'
  1545. rather than from files named `A', `B' and `C'.
  1546. File: diff.info,  Node: Bypassing ed,  Next: Merging Incomplete Lines,  Prev: Marking Conflicts,  Up: diff3 Merging
  1547. Generating the Merged Output Directly
  1548. =====================================
  1549.    With the `-m' or `--merge' option, `diff3' outputs the merged file
  1550. directly.  This is more efficient than using `ed' to generate it, and
  1551. works even with non-text files that `ed' would reject.  If you specify
  1552. `-m' without an `ed' script option, `-A' (`--show-all') is assumed.
  1553.    For example, the command `diff3 -m lao tzu tao' (*note Sample diff3
  1554. Input::. for a copy of the input files) would output the following:
  1555.      <<<<<<< tzu
  1556.      =======
  1557.      The Way that can be told of is not the eternal Way;
  1558.      The name that can be named is not the eternal name.
  1559.      >>>>>>> tao
  1560.      The Nameless is the origin of Heaven and Earth;
  1561.      The Named is the mother of all things.
  1562.      Therefore let there always be non-being,
  1563.        so we may see their subtlety,
  1564.      And let there always be being,
  1565.        so we may see their result.
  1566.      The two are the same,
  1567.      But after they are produced,
  1568.        they have different names.
  1569.      <<<<<<< lao
  1570.      ||||||| tzu
  1571.      They both may be called deep and profound.
  1572.      Deeper and more profound,
  1573.      The door of all subtleties!
  1574.      =======
  1575.      
  1576.        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
  1577.      >>>>>>> tao
  1578. File: diff.info,  Node: Merging Incomplete Lines,  Next: Saving the Changed File,  Prev: Bypassing ed,  Up: diff3 Merging
  1579. How `diff3' Merges Incomplete Lines
  1580. ===================================
  1581.    With `-m', incomplete lines (*note Incomplete Lines::.) are simply
  1582. copied to the output as they are found; if the merged output ends in an
  1583. conflict and one of the input files ends in an incomplete line,
  1584. succeeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere
  1585. other than the start of a line because they are appended to the
  1586. incomplete line.
  1587.    Without `-m', if an `ed' script option is specified and an
  1588. incomplete line is found, `diff3' generates a warning and acts as if a
  1589. newline had been present.
  1590. File: diff.info,  Node: Saving the Changed File,  Prev: Merging Incomplete Lines,  Up: diff3 Merging
  1591. Saving the Changed File
  1592. =======================
  1593.    Traditional Unix `diff3' generates an `ed' script without the
  1594. trailing `w' and and `q' commands that save the changes.  System V
  1595. `diff3' generates these extra commands.  GNU `diff3' normally behaves
  1596. like traditional Unix `diff3', but with the `-i' option it behaves like
  1597. System V `diff3' and appends the `w' and `q' commands.
  1598.    The `-i' option requires one of the `ed' script options `-AeExX3',
  1599. and is incompatible with the merged output option `-m'.
  1600. File: diff.info,  Node: Interactive Merging,  Next: Merging with patch,  Prev: diff3 Merging,  Up: Top
  1601. Interactive Merging with `sdiff'
  1602. ********************************
  1603.    With `sdiff', you can merge two files interactively based on a
  1604. side-by-side `-y' format comparison (*note Side by Side::.).  Use `-o
  1605. FILE' or `--output=FILE' to specify where to put the merged text.
  1606. *Note Invoking sdiff::, for more details on the options to `sdiff'.
  1607.    Another way to merge files interactively is to use the Emacs Lisp
  1608. package `emerge'.  *Note emerge: (emacs)emerge, for more information.
  1609. * Menu:
  1610. * sdiff Option Summary::Summary of `sdiff' options.
  1611. * Merge Commands::    Merging two files interactively.
  1612. File: diff.info,  Node: sdiff Option Summary,  Next: Merge Commands,  Up: Interactive Merging
  1613. Specifying `diff' Options to `sdiff'
  1614. ====================================
  1615.    The following `sdiff' options have the same meaning as for `diff'.
  1616. *Note diff Options::, for the use of these options.
  1617.      -a -b -d -i -t -v
  1618.      -B -H -I REGEXP
  1619.      
  1620.      --ignore-blank-lines  --ignore-case
  1621.      --ignore-matching-lines=REGEXP  --ignore-space-change
  1622.      --left-column  --minimal  --speed-large-files
  1623.      --suppress-common-lines  --expand-tabs
  1624.      --text  --version  --width=COLUMNS
  1625.    For historical reasons, `sdiff' has alternate names for some
  1626. options.  The `-l' option is equivalent to the `--left-column' option,
  1627. and similarly `-s' is equivalent to `--suppress-common-lines'.  The
  1628. meaning of the `sdiff' `-w' and `-W' options is interchanged from that
  1629. of `diff': with `sdiff', `-w COLUMNS' is equivalent to
  1630. `--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'.
  1631. `sdiff' without the `-o' option is equivalent to `diff' with the `-y'
  1632. or `--side-by-side' option (*note Side by Side::.).
  1633. File: diff.info,  Node: Merge Commands,  Prev: sdiff Option Summary,  Up: Interactive Merging
  1634. Merge Commands
  1635. ==============
  1636.    Groups of common lines, with a blank gutter, are copied from the
  1637. first file to the output.  After each group of differing lines, `sdiff'
  1638. prompts with `%' and pauses, waiting for one of the following commands.
  1639. Follow each command with RET.
  1640.      Discard both versions.  Invoke a text editor on an empty temporary
  1641.      file, then copy the resulting file to the output.
  1642.      Concatenate the two versions, edit the result in a temporary file,
  1643.      then copy the edited result to the output.
  1644.      Edit a copy of the left version, then copy the result to the
  1645.      output.
  1646.      Edit a copy of the right version, then copy the result to the
  1647.      output.
  1648.      Copy the left version to the output.
  1649.      Quit.
  1650.      Copy the right version to the output.
  1651.      Silently copy common lines.
  1652.      Verbosely copy common lines.  This is the default.
  1653.    The text editor invoked is specified by the `EDITOR' environment
  1654. variable if it is set.  The default is system-dependent.
  1655. File: diff.info,  Node: Merging with patch,  Next: Making Patches,  Prev: Interactive Merging,  Up: Top
  1656. Merging with `patch'
  1657. ********************
  1658.    `patch' takes comparison output produced by `diff' and applies the
  1659. differences to a copy of the original file, producing a patched
  1660. version.  With `patch', you can distribute just the changes to a set of
  1661. files instead of distributing the entire file set; your correspondents
  1662. can apply `patch' to update their copy of the files with your changes.
  1663. `patch' automatically determines the diff format, skips any leading or
  1664. trailing headers, and uses the headers to determine which file to
  1665. patch.  This lets your correspondents feed an article or message
  1666. containing a difference listing directly to `patch'.
  1667.    `patch' detects and warns about common problems like forward
  1668. patches.  It saves the original version of the files it patches, and
  1669. saves any patches that it could not apply.  It can also maintain a
  1670. `patchlevel.h' file to ensures that your correspondents apply diffs in
  1671. the proper order.
  1672.    `patch' accepts a series of diffs in its standard input, usually
  1673. separated by headers that specify which file to patch.  It applies
  1674. `diff' hunks (*note Hunks::.) one by one.  If a hunk does not exactly
  1675. match the original file, `patch' uses heuristics to try to patch the
  1676. file as well as it can.  If no approximate match can be found, `patch'
  1677. rejects the hunk and skips to the next hunk.  `patch' normally replaces
  1678. each file F with its new version, saving the original file in `F.orig',
  1679. and putting reject hunks (if any) into `F.rej'.
  1680.    *Note Invoking patch::, for detailed information on the options to
  1681. `patch'.  *Note Backups::, for more information on how `patch' names
  1682. backup files.  *Note Rejects::, for more information on where `patch'
  1683. puts reject hunks.
  1684. * Menu:
  1685. * patch Input::        Selecting the type of `patch' input.
  1686. * Imperfect::        Dealing with imperfect patches.
  1687. * Empty Files::        Removing empty files after patching.
  1688. * Multiple Patches::    Handling multiple patches in a file specially.
  1689. * patch Messages::    Messages and questions `patch' can produce.
  1690. File: diff.info,  Node: patch Input,  Next: Imperfect,  Up: Merging with patch
  1691. Selecting the `patch' Input Format
  1692. ==================================
  1693.    `patch' normally determines which `diff' format the patch file uses
  1694. by examining its contents.  For patch files that contain particularly
  1695. confusing leading text, you might need to use one of the following
  1696. options to force `patch' to interpret the patch file as a certain
  1697. format of diff.  The output formats listed here are the only ones that
  1698. `patch' can understand.
  1699. `--context'
  1700.      context diff.
  1701. `--ed'
  1702.      `ed' script.
  1703. `--normal'
  1704.      normal diff.
  1705. `--unified'
  1706.      unified diff.
  1707. File: diff.info,  Node: Imperfect,  Next: Empty Files,  Prev: patch Input,  Up: Merging with patch
  1708. Applying Imperfect Patches
  1709. ==========================
  1710.    `patch' tries to skip any leading text in the patch file, apply the
  1711. diff, and then skip any trailing text.  Thus you can feed a news article
  1712. or mail message directly to `patch', and it should work.  If the entire
  1713. diff is indented by a constant amount of white space, `patch'
  1714. automatically ignores the indentation.
  1715.    However, certain other types of imperfect input require user
  1716. intervention.
  1717. * Menu:
  1718. * Changed White Space::    When tabs and spaces don't match exactly.
  1719. * Reversed Patches::    Applying reversed patches correctly.
  1720. * Inexact::        Helping `patch' find close matches.
  1721. File: diff.info,  Node: Changed White Space,  Next: Reversed Patches,  Up: Imperfect
  1722. Applying Patches with Changed White Space
  1723. -----------------------------------------
  1724.    Sometimes mailers, editors, or other programs change spaces into
  1725. tabs, or vice versa.  If this happens to a patch file or an input file,
  1726. the files might look the same, but `patch' will not be able to match
  1727. them properly.  If this problem occurs, use the `-l' or
  1728. `--ignore-white-space' option, which makes `patch' compare white space
  1729. loosely so that any sequence of white space in the patch file matches
  1730. any sequence of white space in the input files.  Non-white-space
  1731. characters must still match exactly.  Each line of the context must
  1732. still match a line in the input file.
  1733. File: diff.info,  Node: Reversed Patches,  Next: Inexact,  Prev: Changed White Space,  Up: Imperfect
  1734. Applying Reversed Patches
  1735. -------------------------
  1736.    Sometimes people run `diff' with the new file first instead of
  1737. second.  This creates a diff that is "reversed".  To apply such
  1738. patches, give `patch' the `-R' or `--reverse' option.  `patch' then
  1739. attempts to swap each hunk around before applying it.  Rejects come out
  1740. in the swapped format.  The `-R' option does not work with `ed' scripts
  1741. because there is too little information in them to reconstruct the
  1742. reverse operation.
  1743.    Often `patch' can guess that the patch is reversed.  If the first
  1744. hunk of a patch fails, `patch' reverses the hunk to see if it can apply
  1745. it that way.  If it can, `patch' asks you if you want to have the `-R'
  1746. option set; if it can't, `patch' continues to apply the patch normally.
  1747. This method cannot detect a reversed patch if it is a normal diff and
  1748. the first command is an append (which should have been a delete) since
  1749. appends always succeed, because a null context matches anywhere.  But
  1750. most patches add or change lines rather than delete them, so most
  1751. reversed normal diffs begin with a delete, which fails, and `patch'
  1752. notices.
  1753.    If you apply a patch that you have already applied, `patch' thinks
  1754. it is a reversed patch and offers to un-apply the patch.  This could be
  1755. construed as a feature.  If you did this inadvertently and you don't
  1756. want to un-apply the patch, just answer `n' to this offer and to the
  1757. subsequent "apply anyway" question--or type `C-c' to kill the `patch'
  1758. process.
  1759. File: diff.info,  Node: Inexact,  Prev: Reversed Patches,  Up: Imperfect
  1760. Helping `patch' Find Inexact Matches
  1761. ------------------------------------
  1762.    For context diffs, and to a lesser extent normal diffs, `patch' can
  1763. detect when the line numbers mentioned in the patch are incorrect, and
  1764. it attempts to find the correct place to apply each hunk of the patch.
  1765. As a first guess, it takes the line number mentioned in the hunk, plus
  1766. or minus any offset used in applying the previous hunk.  If that is not
  1767. the correct place, `patch' scans both forward and backward for a set of
  1768. lines matching the context given in the hunk.
  1769.    First `patch' looks for a place where all lines of the context
  1770. match.  If it cannot find such a place, and it is reading a context or
  1771. unified diff, and the maximum fuzz factor is set to 1 or more, then
  1772. `patch' makes another scan, ignoring the first and last line of
  1773. context.  If that fails, and the maximum fuzz factor is set to 2 or
  1774. more, it makes another scan, ignoring the first two and last two lines
  1775. of context are ignored.  It continues similarly if the maximum fuzz
  1776. factor is larger.
  1777.    The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor
  1778. to LINES.  This option only applies to context and unified diffs; it
  1779. ignores up to LINES lines while looking for the place to install a
  1780. hunk.  Note that a larger fuzz factor increases the odds of making a
  1781. faulty patch.  The default fuzz factor is 2; it may not be set to more
  1782. than the number of lines of context in the diff, ordinarily 3.
  1783.    If `patch' cannot find a place to install a hunk of the patch, it
  1784. writes the hunk out to a reject file (*note Rejects::., for information
  1785. on how reject files are named).  It writes out rejected hunks in context
  1786. format no matter what form the input patch is in.  If the input is a
  1787. normal or `ed' diff, many of the contexts are simply null.  The line
  1788. numbers on the hunks in the reject file may be different from those in
  1789. the patch file: they show the approximate location where `patch' thinks
  1790. the failed hunks belong in the new file rather than in the old one.
  1791.    As it completes each hunk, `patch' tells you whether the hunk
  1792. succeeded or failed, and if it failed, on which line (in the new file)
  1793. `patch' thinks the hunk should go.  If this is different from the line
  1794. number specified in the diff, it tells you the offset.  A single large
  1795. offset *may* indicate that `patch' installed a hunk in the wrong place.
  1796. `patch' also tells you if it used a fuzz factor to make the match, in
  1797. which case you should also be slightly suspicious.
  1798.    `patch' cannot tell if the line numbers are off in an `ed' script,
  1799. and can only detect wrong line numbers in a normal diff when it finds a
  1800. change or delete command.  It may have the same problem with a context
  1801. diff using a fuzz factor equal to or greater than the number of lines
  1802. of context shown in the diff (typically 3).  In these cases, you should
  1803. probably look at a context diff between your original and patched input
  1804. files to see if the changes make sense.  Compiling without errors is a
  1805. pretty good indication that the patch worked, but not a guarantee.
  1806.    `patch' usually produces the correct results, even when it must make
  1807. many guesses.  However, the results are guaranteed only when the patch
  1808. is applied to an exact copy of the file that the patch was generated
  1809. from.
  1810. File: diff.info,  Node: Empty Files,  Next: Multiple Patches,  Prev: Imperfect,  Up: Merging with patch
  1811. Removing Empty Files
  1812. ====================
  1813.    Sometimes when comparing two directories, the first directory
  1814. contains a file that the second directory does not.  If you give `diff'
  1815. the `-N' or `--new-file' option, it outputs a diff that deletes the
  1816. contents of this file.  By default, `patch' leaves an empty file after
  1817. applying such a diff.  The `-E' or `--remove-empty-files' option to
  1818. `patch' deletes output files that are empty after applying the diff.
  1819. File: diff.info,  Node: Multiple Patches,  Next: patch Messages,  Prev: Empty Files,  Up: Merging with patch
  1820. Multiple Patches in a File
  1821. ==========================
  1822.    If the patch file contains more than one patch, `patch' tries to
  1823. apply each of them as if they came from separate patch files.  This
  1824. means that it determines the name of the file to patch for each patch,
  1825. and that it examines the leading text before each patch for file names
  1826. and prerequisite revision level (*note Making Patches::., for more on
  1827. that topic).
  1828.    For the second and subsequent patches in the patch file, you can give
  1829. options and another original file name by separating their argument
  1830. lists with a `+'.  However, the argument list for a second or
  1831. subsequent patch may not specify a new patch file, since that does not
  1832. make sense.
  1833.    For example, to tell `patch' to strip the first three slashes from
  1834. the name of the first patch in the patch file and none from subsequent
  1835. patches, and to use `code.c' as the first input file, you can use:
  1836.      patch -p3 code.c + -p0 < patchfile
  1837.    The `-S' or `--skip' option ignores the current patch from the patch
  1838. file, but continue looking for the next patch in the file.  Thus, to
  1839. ignore the first and third patches in the patch file, you can use:
  1840.      patch -S + + -S + < patch file
  1841. File: diff.info,  Node: patch Messages,  Prev: Multiple Patches,  Up: Merging with patch
  1842. Messages and Questions from `patch'
  1843. ===================================
  1844.    `patch' can produce a variety of messages, especially if it has
  1845. trouble decoding its input.  In a few situations where it's not sure how
  1846. to proceed, `patch' normally prompts you for more information from the
  1847. keyboard.  There are options to suppress printing non-fatal messages
  1848. and stopping for keyboard input.
  1849.    The message `Hmm...' indicates that `patch' is reading text in the
  1850. patch file, attempting to determine whether there is a patch in that
  1851. text, and if so, what kind of patch it is.
  1852.    You can inhibit all terminal output from `patch', unless an error
  1853. occurs, by using the `-s', `--quiet', or `--silent' option.
  1854.    There are two ways you can prevent `patch' from asking you any
  1855. questions.  The `-f' or `--force' option assumes that you know what you
  1856. are doing.  It assumes the following:
  1857.    * skip patches that do not contain file names in their headers;
  1858.    * patch files even though they have the wrong version for the
  1859.      `Prereq:' line in the patch;
  1860.    * assume that patches are not reversed even if they look like they
  1861.      are.
  1862.    The `-t' or `--batch' option is similar to `-f', in that it
  1863. suppresses questions, but it makes somewhat different assumptions:
  1864.    * skip patches that do not contain file names in their headers (the
  1865.      same as `-f');
  1866.    * skip patches for which the file has the wrong version for the
  1867.      `Prereq:' line in the patch;
  1868.    * assume that patches are reversed if they look like they are.
  1869.    `patch' exits with a non-zero status if it creates any reject files.
  1870. When applying a set of patches in a loop, you should check the exit
  1871. status, so you don't apply a later patch to a partially patched file.
  1872. File: diff.info,  Node: Making Patches,  Next: Invoking cmp,  Prev: Merging with patch,  Up: Top
  1873. Tips for Making Patch Distributions
  1874. ***********************************
  1875.    Here are some things you should keep in mind if you are going to
  1876. distribute patches for updating a software package.
  1877.    Make sure you have specified the file names correctly, either in a
  1878. context diff header or with an `Index:' line.  If you are patching
  1879. files in a subdirectory, be sure to tell the patch user to specify a
  1880. `-p' or `--strip' option as needed.  Take care to not send out reversed
  1881. patches, since these make people wonder whether they have already
  1882. applied the patch.
  1883.    To save people from partially applying a patch before other patches
  1884. that should have gone before it, you can make the first patch in the
  1885. patch file update a file with a name like `patchlevel.h' or
  1886. `version.c', which contains a patch level or version number.  If the
  1887. input file contains the wrong version number, `patch' will complain
  1888. immediately.
  1889.    An even clearer way to prevent this problem is to put a `Prereq:'
  1890. line before the patch.  If the leading text in the patch file contains a
  1891. line that starts with `Prereq:', `patch' takes the next word from that
  1892. line (normally a version number) and checks whether the next input file
  1893. contains that word, preceded and followed by either white space or a
  1894. newline.  If not, `patch' prompts you for confirmation before
  1895. proceeding.  This makes it difficult to accidentally apply patches in
  1896. the wrong order.
  1897.    Since `patch' does not handle incomplete lines properly, make sure
  1898. that all the source files in your program end with a newline whenever
  1899. you release a version.
  1900.    To create a patch that changes an older version of a package into a
  1901. newer version, first make a copy of the older version in a scratch
  1902. directory.  Typically you do that by unpacking a `tar' or `shar'
  1903. archive of the older version.
  1904.    You might be able to reduce the size of the patch by renaming or
  1905. removing some files before making the patch.  If the older version of
  1906. the package contains any files that the newer version does not, or if
  1907. any files have been renamed between the two versions, make a list of
  1908. `rm' and `mv' commands for the user to execute in the old version
  1909. directory before applying the patch.  Then run those commands yourself
  1910. in the scratch directory.
  1911.    If there are any files that you don't need to include in the patch
  1912. because they can easily be rebuilt from other files (for example,
  1913. `TAGS' and output from `yacc' and `makeinfo'), replace the versions in
  1914. the scratch directory with the newer versions, using `rm' and `ln' or
  1915. `cp'.
  1916.    Now you can create the patch.  The de-facto standard `diff' format
  1917. for patch distributions is context format with two lines of context,
  1918. produced by giving `diff' the `-C 2' option.  Do not use less than two
  1919. lines of context, because `patch' typically needs at least two lines
  1920. for proper operation.  Give `diff' the `-P' option in case the newer
  1921. version of the package contains any files that the older one does not.
  1922. Make sure to specify the scratch directory first and the newer
  1923. directory second.
  1924.    Add to the top of the patch a note telling the user any `rm' and
  1925. `mv' commands to run before applying the patch.  Then you can remove
  1926. the scratch directory.
  1927. File: diff.info,  Node: Invoking cmp,  Next: Invoking diff,  Prev: Making Patches,  Up: Top
  1928. Invoking `cmp'
  1929. **************
  1930.    The `cmp' command compares two files, and if they differ, tells the
  1931. first byte and line number where they differ.  Its arguments are as
  1932. follows:
  1933.      cmp OPTIONS... FROM-FILE [TO-FILE]
  1934.    The file name `-' is always the standard input.  `cmp' also uses the
  1935. standard input if one file name is omitted.
  1936.    An exit status of 0 means no differences were found, 1 means some
  1937. differences were found, and 2 means trouble.
  1938. * Menu:
  1939. * cmp Options::        Summary of options to `cmp'.
  1940. File: diff.info,  Node: cmp Options,  Up: Invoking cmp
  1941. Options to `cmp'
  1942. ================
  1943.    Below is a summary of all of the options that GNU `cmp' accepts.
  1944. Most options have two equivalent names, one of which is a single letter
  1945. preceded by `-', and the other of which is a long name preceded by
  1946. `--'.  Multiple single letter options (unless they take an argument)
  1947. can be combined into a single command line word: `-cl' is equivalent to
  1948. `-c -l'.
  1949.      Print the differing characters.  Display control characters as a
  1950.      `^' followed by a letter of the alphabet and precede characters
  1951.      that have the high bit set with `M-' (which stands for "meta").
  1952. `--ignore-initial=BYTES'
  1953.      Ignore any differences in the the first BYTES bytes of the input
  1954.      files.  Treat files with fewer than BYTES bytes as if they are
  1955.      empty.
  1956.      Print the (decimal) offsets and (octal) values of all differing
  1957.      bytes.
  1958. `--print-chars'
  1959.      Print the differing characters.  Display control characters as a
  1960.      `^' followed by a letter of the alphabet and precede characters
  1961.      that have the high bit set with `M-' (which stands for "meta").
  1962. `--quiet'
  1963. `--silent'
  1964.      Do not print anything; only return an exit status indicating
  1965.      whether the files differ.
  1966. `--verbose'
  1967.      Print the (decimal) offsets and (octal) values of all differing
  1968.      bytes.
  1969. `--version'
  1970.      Output the version number of `cmp'.
  1971. File: diff.info,  Node: Invoking diff,  Next: Invoking diff3,  Prev: Invoking cmp,  Up: Top
  1972. Invoking `diff'
  1973. ***************
  1974.    The format for running the `diff' command is:
  1975.      diff OPTIONS... FROM-FILE TO-FILE
  1976.    In the simplest case, `diff' compares the contents of the two files
  1977. FROM-FILE and TO-FILE.  A file name of `-' stands for text read from
  1978. the standard input.  As a special case, `diff - -' compares a copy of
  1979. standard input to itself.
  1980.    If FROM-FILE is a directory and TO-FILE is not, `diff' compares the
  1981. file in FROM-FILE whose file name is that of TO-FILE, and vice versa.
  1982. The non-directory file must not be `-'.
  1983.    If both FROM-FILE and TO-FILE are directories, `diff' compares
  1984. corresponding files in both directories, in alphabetical order; this
  1985. comparison is not recursive unless the `-r' or `--recursive' option is
  1986. given.  `diff' never compares the actual contents of a directory as if
  1987. it were a file.  The file that is fully specified may not be standard
  1988. input, because standard input is nameless and the notion of "file with
  1989. the same name" does not apply.
  1990.    `diff' options begin with `-', so normally FROM-FILE and TO-FILE may
  1991. not begin with `-'.  However, `--' as an argument by itself treats the
  1992. remaining arguments as file names even if they begin with `-'.
  1993.    An exit status of 0 means no differences were found, 1 means some
  1994. differences were found, and 2 means trouble.
  1995. * Menu:
  1996. * diff Options::    Summary of options to `diff'.
  1997. File: diff.info,  Node: diff Options,  Up: Invoking diff
  1998. Options to `diff'
  1999. =================
  2000.    Below is a summary of all of the options that GNU `diff' accepts.
  2001. Most options have two equivalent names, one of which is a single letter
  2002. preceded by `-', and the other of which is a long name preceded by
  2003. `--'.  Multiple single letter options (unless they take an argument)
  2004. can be combined into a single command line word: `-ac' is equivalent to
  2005. `-a -c'.  Long named options can be abbreviated to any unique prefix of
  2006. their name.  Brackets ([ and ]) indicate that an option takes an
  2007. optional argument.
  2008. `-LINES'
  2009.      Show LINES (an integer) lines of context.  This option does not
  2010.      specify an output format by itself; it has no effect unless it is
  2011.      combined with `-c' (*note Context Format::.) or `-u' (*note
  2012.      Unified Format::.).  This option is obsolete.  For proper
  2013.      operation, `patch' typically needs at least two lines of context.
  2014.      Treat all files as text and compare them line-by-line, even if they
  2015.      do not seem to be text.  *Note Binary::.
  2016.      Ignore changes in amount of white space.  *Note White Space::.
  2017.      Ignore changes that just insert or delete blank lines.  *Note
  2018.      Blank Lines::.
  2019. `--brief'
  2020.      Report only whether the files differ, not the details of the
  2021.      differences.  *Note Brief::.
  2022.      Use the context output format.  *Note Context Format::.
  2023. `-C LINES'
  2024. `--context[=LINES]'
  2025.      Use the context output format, showing LINES (an integer) lines of
  2026.      context, or three if LINES is not given.  *Note Context Format::.
  2027.      For proper operation, `patch' typically needs at least two lines of
  2028.      context.
  2029. `--changed-group-format=FORMAT'
  2030.      Use FORMAT to output a line group containing differing lines from
  2031.      both files in if-then-else format.  *Note Line Group Formats::.
  2032.      Change the algorithm perhaps find a smaller set of changes.  This
  2033.      makes `diff' slower (sometimes much slower).  *Note diff
  2034.      Performance::.
  2035. `-D NAME'
  2036.      Make merged `#ifdef' format output, conditional on the preprocessor
  2037.      macro NAME.  *Note If-then-else::.
  2038. `--ed'
  2039.      Make output that is a valid `ed' script.  *Note ed Scripts::.
  2040. `--exclude=PATTERN'
  2041.      When comparing directories, ignore files and subdirectories whose
  2042.      basenames match PATTERN.  *Note Comparing Directories::.
  2043. `--exclude-from=FILE'
  2044.      When comparing directories, ignore files and subdirectories whose
  2045.      basenames match any pattern contained in FILE.  *Note Comparing
  2046.      Directories::.
  2047. `--expand-tabs'
  2048.      Expand tabs to spaces in the output, to preserve the alignment of
  2049.      tabs in the input files.  *Note Tabs::.
  2050.      Make output that looks vaguely like an `ed' script but has changes
  2051.      in the order they appear in the file.  *Note Forward ed::.
  2052. `-F REGEXP'
  2053.      In context and unified format, for each hunk of differences, show
  2054.      some of the last preceding line that matches REGEXP.  *Note
  2055.      Specified Headings::.
  2056. `--forward-ed'
  2057.      Make output that looks vaguely like an `ed' script but has changes
  2058.      in the order they appear in the file.  *Note Forward ed::.
  2059.      This option currently has no effect; it is present for Unix
  2060.      compatibility.
  2061.      Use heuristics to speed handling of large files that have numerous
  2062.      scattered small changes.  *Note diff Performance::.
  2063. `--horizon-lines=LINES'
  2064.      Do not discard the last LINES lines of the common prefix and the
  2065.      first LINES lines of the common suffix.  *Note diff Performance::.
  2066.      Ignore changes in case; consider upper- and lower-case letters
  2067.      equivalent.  *Note Case Folding::.
  2068. `-I REGEXP'
  2069.      Ignore changes that just insert or delete lines that match REGEXP.
  2070.      *Note Specified Folding::.
  2071. `--ifdef=NAME'
  2072.      Make merged if-then-else output using FORMAT.  *Note
  2073.      If-then-else::.
  2074. `--ignore-all-space'
  2075.      Ignore white space when comparing lines.  *Note White Space::.
  2076. `--ignore-blank-lines'
  2077.      Ignore changes that just insert or delete blank lines.  *Note
  2078.      Blank Lines::.
  2079. `--ignore-case'
  2080.      Ignore changes in case; consider upper- and lower-case to be the
  2081.      same.  *Note Case Folding::.
  2082. `--ignore-matching-lines=REGEXP'
  2083.      Ignore changes that just insert or delete lines that match REGEXP.
  2084.      *Note Specified Folding::.
  2085. `--ignore-space-change'
  2086.      Ignore changes in amount of white space.  *Note White Space::.
  2087. `--initial-tab'
  2088.      Output a tab rather than a space before the text of a line in
  2089.      normal or context format.  This causes the alignment of tabs in
  2090.      the line to look normal.  *Note Tabs::.
  2091.      Pass the output through `pr' to paginate it.  *Note Pagination::.
  2092. `-L LABEL'
  2093.      Use LABEL instead of the file name in the context format (*note
  2094.      Context Format::.) and unified format (*note Unified Format::.)
  2095.      headers.  *Note RCS::.
  2096. `--label=LABEL'
  2097.      Use LABEL instead of the file name in the context format (*note
  2098.      Context Format::.) and unified format (*note Unified Format::.)
  2099.      headers.
  2100. `--left-column'
  2101.      Print only the left column of two common lines in side by side
  2102.      format.  *Note Side by Side Format::.
  2103. `--line-format=FORMAT'
  2104.      Use FORMAT to output all input lines in if-then-else format.
  2105.      *Note Line Formats::.
  2106. `--minimal'
  2107.      Change the algorithm to perhaps find a smaller set of changes.
  2108.      This makes `diff' slower (sometimes much slower).  *Note diff
  2109.      Performance::.
  2110.      Output RCS-format diffs; like `-f' except that each command
  2111.      specifies the number of lines affected.  *Note RCS::.
  2112. `--new-file'
  2113.      In directory comparison, if a file is found in only one directory,
  2114.      treat it as present but empty in the other directory.  *Note
  2115.      Comparing Directories::.
  2116. `--new-group-format=FORMAT'
  2117.      Use FORMAT to output a group of lines taken from just the second
  2118.      file in if-then-else format.  *Note Line Group Formats::.
  2119. `--new-line-format=FORMAT'
  2120.      Use FORMAT to output a line taken from just the second file in
  2121.      if-then-else format.  *Note Line Formats::.
  2122. `--old-group-format=FORMAT'
  2123.      Use FORMAT to output a group of lines taken from just the first
  2124.      file in if-then-else format.  *Note Line Group Formats::.
  2125. `--old-line-format=FORMAT'
  2126.      Use FORMAT to output a line taken from just the first file in
  2127.      if-then-else format.  *Note Line Formats::.
  2128.      Show which C function each change is in.  *Note C Function
  2129.      Headings::.
  2130.      When comparing directories, if a file appears only in the second
  2131.      directory of the two, treat it as present but empty in the other.
  2132.      *Note Comparing Directories::.
  2133. `--paginate'
  2134.      Pass the output through `pr' to paginate it.  *Note Pagination::.
  2135.      Report only whether the files differ, not the details of the
  2136.      differences.  *Note Brief::.
  2137.      When comparing directories, recursively compare any subdirectories
  2138.      found.  *Note Comparing Directories::.
  2139. `--rcs'
  2140.      Output RCS-format diffs; like `-f' except that each command
  2141.      specifies the number of lines affected.  *Note RCS::.
  2142. `--recursive'
  2143.      When comparing directories, recursively compare any subdirectories
  2144.      found.  *Note Comparing Directories::.
  2145. `--report-identical-files'
  2146.      Report when two files are the same.  *Note Comparing Directories::.
  2147.      Report when two files are the same.  *Note Comparing Directories::.
  2148. `-S FILE'
  2149.      When comparing directories, start with the file FILE.  This is
  2150.      used for resuming an aborted comparison.  *Note Comparing
  2151.      Directories::.
  2152. `--sdiff-merge-assist'
  2153.      Print extra information to help `sdiff'.  `sdiff' uses this option
  2154.      when it runs `diff'.  This option is not intended for users to use
  2155.      directly.
  2156. `--show-c-function'
  2157.      Show which C function each change is in.  *Note C Function
  2158.      Headings::.
  2159. `--show-function-line=REGEXP'
  2160.      In context and unified format, for each hunk of differences, show
  2161.      some of the last preceding line that matches REGEXP.  *Note
  2162.      Specified Headings::.
  2163. `--side-by-side'
  2164.      Use the side by side output format.  *Note Side by Side Format::.
  2165. `--speed-large-files'
  2166.      Use heuristics to speed handling of large files that have numerous
  2167.      scattered small changes.  *Note diff Performance::.
  2168. `--starting-file=FILE'
  2169.      When comparing directories, start with the file FILE.  This is
  2170.      used for resuming an aborted comparison.  *Note Comparing
  2171.      Directories::.
  2172. `--suppress-common-lines'
  2173.      Do not print common lines in side by side format.  *Note Side by
  2174.      Side Format::.
  2175.      Expand tabs to spaces in the output, to preserve the alignment of
  2176.      tabs in the input files.  *Note Tabs::.
  2177.      Output a tab rather than a space before the text of a line in
  2178.      normal or context format.  This causes the alignment of tabs in
  2179.      the line to look normal.  *Note Tabs::.
  2180. `--text'
  2181.      Treat all files as text and compare them line-by-line, even if they
  2182.      do not appear to be text.  *Note Binary::.
  2183.      Use the unified output format.  *Note Unified Format::.
  2184. `--unchanged-group-format=FORMAT'
  2185.      Use FORMAT to output a group of common lines taken from both files
  2186.      in if-then-else format.  *Note Line Group Formats::.
  2187. `--unchanged-line-format=FORMAT'
  2188.      Use FORMAT to output a line common to both files in if-then-else
  2189.      format.  *Note Line Formats::.
  2190. `--unidirectional-new-file'
  2191.      When comparing directories, if a file appears only in the second
  2192.      directory of the two, treat it as present but empty in the other.
  2193.      *Note Comparing Directories::.
  2194. `-U LINES'
  2195. `--unified[=LINES]'
  2196.      Use the unified output format, showing LINES (an integer) lines of
  2197.      context, or three if LINES is not given.  *Note Unified Format::.
  2198.      For proper operation, `patch' typically needs at least two lines of
  2199.      context.
  2200. `--version'
  2201.      Output the version number of `diff'.
  2202.      Ignore white space when comparing lines.  *Note White Space::.
  2203. `-W COLUMNS'
  2204. `--width=COLUMNS'
  2205.      Use an output width of COLUMNS in side by side format.  *Note Side
  2206.      by Side Format::.
  2207. `-x PATTERN'
  2208.      When comparing directories, ignore files and subdirectories whose
  2209.      basenames match PATTERN.  *Note Comparing Directories::.
  2210. `-X FILE'
  2211.      When comparing directories, ignore files and subdirectories whose
  2212.      basenames match any pattern contained in FILE.  *Note Comparing
  2213.      Directories::.
  2214.      Use the side by side output format.  *Note Side by Side Format::.
  2215. File: diff.info,  Node: Invoking diff3,  Next: Invoking patch,  Prev: Invoking diff,  Up: Top
  2216. Invoking `diff3'
  2217. ****************
  2218.    The `diff3' command compares three files and outputs descriptions of
  2219. their differences.  Its arguments are as follows:
  2220.      diff3 OPTIONS... MINE OLDER YOURS
  2221.    The files to compare are MINE, OLDER, and YOURS.  At most one of
  2222. these three file names may be `-', which tells `diff3' to read the
  2223. standard input for that file.
  2224.    An exit status of 0 means `diff3' was successful, 1 means some
  2225. conflicts were found, and 2 means trouble.
  2226. * Menu:
  2227. * diff3 Options::        Summary of options to `diff3'.
  2228. File: diff.info,  Node: diff3 Options,  Up: Invoking diff3
  2229. Options to `diff3'
  2230. ==================
  2231.    Below is a summary of all of the options that GNU `diff3' accepts.
  2232. Multiple single letter options (unless they take an argument) can be
  2233. combined into a single command line argument.
  2234.      Treat all files as text and compare them line-by-line, even if they
  2235.      do not appear to be text.  *Note Binary::.
  2236.      Incorporate all changes from OLDER to YOURS into MINE, surrounding
  2237.      all conflicts with bracket lines.  *Note Marking Conflicts::.
  2238.      Generate an `ed' script that incorporates all the changes from
  2239.      OLDER to YOURS into MINE.  *Note Which Changes::.
  2240.      Like `-e', except bracket lines from overlapping changes' first
  2241.      and third files.  *Note Marking Conflicts::.  With `-e', an
  2242.      overlapping change looks like this:
  2243.           <<<<<<< MINE
  2244.           lines from MINE
  2245.           =======
  2246.           lines from YOURS
  2247.           >>>>>>> YOURS
  2248. `--ed'
  2249.      Generate an `ed' script that incorporates all the changes from
  2250.      OLDER to YOURS into MINE.  *Note Which Changes::.
  2251. `--easy-only'
  2252.      Like `-e', except output only the nonoverlapping changes.  *Note
  2253.      Which Changes::.
  2254.      Generate `w' and `q' commands at the end of the `ed' script for
  2255.      System V compatibility.  This option must be combined with one of
  2256.      the `-AeExX3' options, and may not be combined with `-m'.  *Note
  2257.      Saving the Changed File::.
  2258. `--initial-tab'
  2259.      Output a tab rather than two spaces before the text of a line in
  2260.      normal format.  This causes the alignment of tabs in the line to
  2261.      look normal.  *Note Tabs::.
  2262. `-L LABEL'
  2263. `--label=LABEL'
  2264.      Use the label LABEL for the brackets output by the `-A', `-E' and
  2265.      `-X' options.  This option may be given up to three times, one for
  2266.      each input file.  The default labels are the names of the input
  2267.      files.  Thus `diff3 -L X -L Y -L Z -m A B C' acts like `diff3 -m A
  2268.      B C', except that the output looks like it came from files named
  2269.      `X', `Y' and `Z' rather than from files named `A', `B' and `C'.
  2270.      *Note Marking Conflicts::.
  2271. `--merge'
  2272.      Apply the edit script to the first file and send the result to
  2273.      standard output.  Unlike piping the output from `diff3' to `ed',
  2274.      this works even for binary files and incomplete lines.  `-A' is
  2275.      assumed if no edit script option is specified.  *Note Bypassing
  2276.      ed::.
  2277. `--overlap-only'
  2278.      Like `-e', except output only the overlapping changes.  *Note
  2279.      Which Changes::.
  2280. `--show-all'
  2281.      Incorporate all unmerged changes from OLDER to YOURS into MINE,
  2282.      surrounding all overlapping changes with bracket lines.  *Note
  2283.      Marking Conflicts::.
  2284. `--show-overlap'
  2285.      Like `-e', except bracket lines from overlapping changes' first
  2286.      and third files.  *Note Marking Conflicts::.
  2287.      Output a tab rather than two spaces before the text of a line in
  2288.      normal format.  This causes the alignment of tabs in the line to
  2289.      look normal.  *Note Tabs::.
  2290. `--text'
  2291.      Treat all files as text and compare them line-by-line, even if they
  2292.      do not appear to be text.  *Note Binary::.
  2293. `--version'
  2294.      Output the version number of `diff3'.
  2295.      Like `-e', except output only the overlapping changes.  *Note
  2296.      Which Changes::.
  2297.      Like `-E', except output only the overlapping changes.  In other
  2298.      words, like `-x', except bracket changes as in `-E'.  *Note
  2299.      Marking Conflicts::.
  2300.      Like `-e', except output only the nonoverlapping changes.  *Note
  2301.      Which Changes::.
  2302. File: diff.info,  Node: Invoking patch,  Next: Invoking sdiff,  Prev: Invoking diff3,  Up: Top
  2303. Invoking `patch'
  2304. ****************
  2305.    Normally `patch' is invoked like this:
  2306.      patch <PATCHFILE
  2307.    The full format for invoking `patch' is:
  2308.      patch OPTIONS... [ORIGFILE [PATCHFILE]] [+ OPTIONS... [ORIGFILE]]...
  2309.    If you do not specify PATCHFILE, or if PATCHFILE is `-', `patch'
  2310. reads the patch (that is, the `diff' output) from the standard input.
  2311.    You can specify one or more of the original files as ORIG arguments;
  2312. each one and options for interpreting it is separated from the others
  2313. with a `+'.  *Note Multiple Patches::, for more information.
  2314.    If you do not specify an input file on the command line, `patch'
  2315. tries to figure out from the "leading text" (any text in the patch that
  2316. comes before the `diff' output) which file to edit.  In the header of a
  2317. context or unified diff, `patch' looks in lines beginning with `***',
  2318. `---', or `+++'; among those, it chooses the shortest name of an
  2319. existing file.  Otherwise, if there is an `Index:' line in the leading
  2320. text, `patch' tries to use the file name from that line.  If `patch'
  2321. cannot figure out the name of an existing file from the leading text,
  2322. it prompts you for the name of the file to patch.
  2323.    If the input file does not exist or is read-only, and a suitable RCS
  2324. or SCCS file exists, `patch' attempts to check out or get the file
  2325. before proceeding.
  2326.    By default, `patch' replaces the original input file with the
  2327. patched version, after renaming the original file into a backup file
  2328. (*note Backups::., for a description of how `patch' names backup
  2329. files).  You can also specify where to put the output with the `-o
  2330. OUTPUT-FILE' or `--output=OUTPUT-FILE' option.
  2331. * Menu:
  2332. * patch Directories::    Changing directory and stripping paths.
  2333. * Backups::        Backup file names.
  2334. * Rejects::        Reject file names.
  2335. * patch Options::    Summary table of options to `patch'.
  2336. File: diff.info,  Node: patch Directories,  Next: Backups,  Up: Invoking patch
  2337. Applying Patches in Other Directories
  2338. =====================================
  2339.    The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch'
  2340. makes directory DIRECTORY the current directory for interpreting both
  2341. file names in the patch file, and file names given as arguments to
  2342. other options (such as `-B' and `-o').  For example, while in a news
  2343. reading program, you can patch a file in the `/usr/src/emacs' directory
  2344. directly from the article containing the patch like this:
  2345.      | patch -d /usr/src/emacs
  2346.    Sometimes the file names given in a patch contain leading
  2347. directories, but you keep your files in a directory different from the
  2348. one given in the patch.  In those cases, you can use the `-p[NUMBER]'
  2349. or `--strip[=NUMBER]' option to set the file name strip count to
  2350. NUMBER.  The strip count tells `patch' how many slashes, along with the
  2351. directory names between them, to strip from the front of file names.
  2352. `-p' with no NUMBER given is equivalent to `-p0'.  By default, `patch'
  2353. strips off all leading paths, leaving just the base file names, except
  2354. that when a file name given in the patch is a relative path and all of
  2355. its leading directories already exist, `patch' does not strip off the
  2356. leading path.  (A "relative" path is one that does not start with a
  2357. slash.)
  2358.    `patch' looks for each file (after any slashes have been stripped)
  2359. in the current directory, or if you used the `-d DIRECTORY' option, in
  2360. that directory.
  2361.    For example, suppose the file name in the patch file is
  2362. `/gnu/src/emacs/etc/NEWS'.  Using `-p' or `-p0' gives the entire file
  2363. name unmodified, `-p1' gives `gnu/src/emacs/etc/NEWS' (no leading
  2364. slash), `-p4' gives `etc/NEWS', and not specifying `-p' at all gives
  2365. `NEWS'.
  2366. File: diff.info,  Node: Backups,  Next: Rejects,  Prev: patch Directories,  Up: Invoking patch
  2367. Backup File Names
  2368. =================
  2369.    Normally, `patch' renames an original input file into a backup file
  2370. by appending to its name the extension `.orig', or `~' on systems that
  2371. do not support long file names.  The `-b BACKUP-SUFFIX' or
  2372. `--suffix=BACKUP-SUFFIX' option uses BACKUP-SUFFIX as the backup
  2373. extension instead.
  2374.    Alternately, you can specify the extension for backup files with the
  2375. `SIMPLE_BACKUP_SUFFIX' environment variable, which the options override.
  2376.    `patch' can also create numbered backup files the way GNU Emacs
  2377. does.  With this method, instead of having a single backup of each file,
  2378. `patch' makes a new backup file name each time it patches a file.  For
  2379. example, the backups of a file named `sink' would be called,
  2380. successively, `sink.~1~', `sink.~2~', `sink.~3~', etc.
  2381.    The `-V BACKUP-STYLE' or `--version-control=BACKUP-STYLE' option
  2382. takes as an argument a method for creating backup file names.  You can
  2383. alternately control the type of backups that `patch' makes with the
  2384. `VERSION_CONTROL' environment variable, which the `-V' option
  2385. overrides.  The value of the `VERSION_CONTROL' environment variable and
  2386. the argument to the `-V' option are like the GNU Emacs
  2387. `version-control' variable (*note emacs: Backups., for more information
  2388. on backup versions in Emacs).  They also recognize synonyms that are
  2389. more descriptive.  The valid values are listed below; unique
  2390. abbreviations are acceptable.
  2391. `numbered'
  2392.      Always make numbered backups.
  2393. `nil'
  2394. `existing'
  2395.      Make numbered backups of files that already have them, simple
  2396.      backups of the others.  This is the default.
  2397. `never'
  2398. `simple'
  2399.      Always make simple backups.
  2400.    Alternately, you can tell `patch' to prepend a prefix, such as a
  2401. directory name, to produce backup file names.  The `-B BACKUP-PREFIX'
  2402. or `--prefix=BACKUP-PREFIX' option makes backup files by prepending
  2403. BACKUP-PREFIX to them.  If you use this option, `patch' ignores any
  2404. `-b' option that you give.
  2405.    If the backup file already exists, `patch' creates a new backup file
  2406. name by changing the first lowercase letter in the last component of
  2407. the file name into uppercase.  If there are no more lowercase letters
  2408. in the name, it removes the first character from the name.  It repeats
  2409. this process until it comes up with a backup file name that does not
  2410. already exist.
  2411.    If you specify the output file with the `-o' option, that file is
  2412. the one that is backed up, not the input file.
  2413. File: diff.info,  Node: Rejects,  Next: patch Options,  Prev: Backups,  Up: Invoking patch
  2414. Reject File Names
  2415. =================
  2416.    The names for reject files (files containing patches that `patch'
  2417. could not find a place to apply) are normally the name of the output
  2418. file with `.rej' appended (or `#' on systems that do not support long
  2419. file names).
  2420.    Alternatively, you can tell `patch' to place all of the rejected
  2421. patches in a single file.  The `-r REJECT-FILE' or
  2422. `--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file
  2423. name.
  2424. File: diff.info,  Node: patch Options,  Prev: Rejects,  Up: Invoking patch
  2425. Options to `patch'
  2426. ==================
  2427.    Here is a summary of all of the options that `patch' accepts.  Older
  2428. versions of `patch' do not accept long-named options or the `-t', `-E',
  2429. or `-V' options.
  2430.    Multiple single-letter options that do not take an argument can be
  2431. combined into a single command line argument (with only one dash).
  2432. Brackets ([ and ]) indicate that an option takes an optional argument.
  2433. `-b BACKUP-SUFFIX'
  2434.      Use BACKUP-SUFFIX as the backup extension instead of `.orig' or
  2435.      `~'.  *Note Backups::.
  2436. `-B BACKUP-PREFIX'
  2437.      Use BACKUP-PREFIX as a prefix to the backup file name.  If this
  2438.      option is specified, any `-b' option is ignored.  *Note Backups::.
  2439. `--batch'
  2440.      Do not ask any questions.  *Note patch Messages::.
  2441. `--context'
  2442.      Interpret the patch file as a context diff.  *Note patch Input::.
  2443. `-d DIRECTORY'
  2444. `--directory=DIRECTORY'
  2445.      Makes directory DIRECTORY the current directory for interpreting
  2446.      both file names in the patch file, and file names given as
  2447.      arguments to other options.  *Note patch Directories::.
  2448. `-D NAME'
  2449.      Make merged if-then-else output using FORMAT.  *Note
  2450.      If-then-else::.
  2451. `--debug=NUMBER'
  2452.      Set internal debugging flags.  Of interest only to `patch'
  2453.      patchers.
  2454. `--ed'
  2455.      Interpret the patch file as an `ed' script.  *Note patch Input::.
  2456.      Remove output files that are empty after the patches have been
  2457.      applied.  *Note Empty Files::.
  2458.      Assume that the user knows exactly what he or she is doing, and do
  2459.      not ask any questions.  *Note patch Messages::.
  2460. `-F LINES'
  2461.      Set the maximum fuzz factor to LINES.  *Note Inexact::.
  2462. `--force'
  2463.      Assume that the user knows exactly what he or she is doing, and do
  2464.      not ask any questions.  *Note patch Messages::.
  2465. `--forward'
  2466.      Ignore patches that `patch' thinks are reversed or already applied.
  2467.      See also `-R'.  *Note Reversed Patches::.
  2468. `--fuzz=LINES'
  2469.      Set the maximum fuzz factor to LINES.  *Note Inexact::.
  2470. `--help'
  2471.      Print a summary of the options that `patch' recognizes, then exit.
  2472. `--ifdef=NAME'
  2473.      Make merged if-then-else output using FORMAT.  *Note
  2474.      If-then-else::.
  2475. `--ignore-white-space'
  2476.      Let any sequence of white space in the patch file match any
  2477.      sequence of white space in the input file.  *Note Changed White
  2478.      Space::.
  2479. `--normal'
  2480.      Interpret the patch file as a normal diff.  *Note patch Input::.
  2481.      Ignore patches that `patch' thinks are reversed or already applied.
  2482.      See also `-R'.  *Note Reversed Patches::.
  2483. `-o OUTPUT-FILE'
  2484. `--output=OUTPUT-FILE'
  2485.      Use OUTPUT-FILE as the output file name.  *Note patch Options::.
  2486. `-p[NUMBER]'
  2487.      Set the file name strip count to NUMBER.  *Note patch
  2488.      Directories::.
  2489. `--prefix=BACKUP-PREFIX'
  2490.      Use BACKUP-PREFIX as a prefix to the backup file name.  If this
  2491.      option is specified, any `-b' option is ignored.  *Note Backups::.
  2492. `--quiet'
  2493.      Work silently unless an error occurs.  *Note patch Messages::.
  2494. `-r REJECT-FILE'
  2495.      Use REJECT-FILE as the reject file name.  *Note Rejects::.
  2496.      Assume that this patch was created with the old and new files
  2497.      swapped.  *Note Reversed Patches::.
  2498. `--reject-file=REJECT-FILE'
  2499.      Use REJECT-FILE as the reject file name.  *Note Rejects::.
  2500. `--remove-empty-files'
  2501.      Remove output files that are empty after the patches have been
  2502.      applied.  *Note Empty Files::.
  2503. `--reverse'
  2504.      Assume that this patch was created with the old and new files
  2505.      swapped.  *Note Reversed Patches::.
  2506.      Work silently unless an error occurs.  *Note patch Messages::.
  2507.      Ignore this patch from the patch file, but continue looking for
  2508.      the next patch in the file.  *Note Multiple Patches::.
  2509. `--silent'
  2510.      Work silently unless an error occurs.  *Note patch Messages::.
  2511. `--skip'
  2512.      Ignore this patch from the patch file, but continue looking for
  2513.      the next patch in the file.  *Note Multiple Patches::.
  2514. `--strip[=NUMBER]'
  2515.      Set the file name strip count to NUMBER.  *Note patch
  2516.      Directories::.
  2517. `--suffix=BACKUP-SUFFIX'
  2518.      Use BACKUP-SUFFIX as the backup extension instead of `.orig' or
  2519.      `~'.  *Note Backups::.
  2520.      Do not ask any questions.  *Note patch Messages::.
  2521. `--unified'
  2522.      Interpret the patch file as a unified diff.  *Note patch Input::.
  2523.      Output the revision header and patch level of `patch'.
  2524. `-V BACKUP-STYLE'
  2525.      Select the kind of backups to make.  *Note Backups::.
  2526. `--version'
  2527.      Output the revision header and patch level of `patch', then exit.
  2528. `--version=control=BACKUP-STYLE'
  2529.      Select the kind of backups to make.  *Note Backups::.
  2530. `-x NUMBER'
  2531.      Set internal debugging flags.  Of interest only to `patch'
  2532.      patchers.
  2533. File: diff.info,  Node: Invoking sdiff,  Next: Incomplete Lines,  Prev: Invoking patch,  Up: Top
  2534. Invoking `sdiff'
  2535. ****************
  2536.    The `sdiff' command merges two files and interactively outputs the
  2537. results.  Its arguments are as follows:
  2538.      sdiff -o OUTFILE OPTIONS... FROM-FILE TO-FILE
  2539.    This merges FROM-FILE with TO-FILE, with output to OUTFILE.  If
  2540. FROM-FILE is a directory and TO-FILE is not, `sdiff' compares the file
  2541. in FROM-FILE whose file name is that of TO-FILE, and vice versa.
  2542. fROM-FILE and TO-FILE may not both be directories.
  2543.    `sdiff' options begin with `-', so normally FROM-FILE and TO-FILE
  2544. may not begin with `-'.  However, `--' as an argument by itself treats
  2545. the remaining arguments as file names even if they begin with `-'.  You
  2546. may not use `-' as an input file.
  2547.    An exit status of 0 means no differences were found, 1 means some
  2548. differences were found, and 2 means trouble.
  2549.    `sdiff' without `-o' (or `--output') produces a side-by-side
  2550. difference.  This usage is obsolete; use `diff --side-by-side' instead.
  2551. * Menu:
  2552. * sdiff Options::    Summary of options to `diff'.
  2553. File: diff.info,  Node: sdiff Options,  Up: Invoking sdiff
  2554. Options to `sdiff'
  2555. ==================
  2556.    Below is a summary of all of the options that GNU `sdiff' accepts.
  2557. Each option has two equivalent names, one of which is a single letter
  2558. preceded by `-', and the other of which is a long name preceded by
  2559. `--'.  Multiple single letter options (unless they take an argument)
  2560. can be combined into a single command line argument.  Long named
  2561. options can be abbreviated to any unique prefix of their name.
  2562.      Treat all files as text and compare them line-by-line, even if they
  2563.      do not appear to be text.  *Note Binary::.
  2564.      Ignore changes in amount of white space.  *Note White Space::.
  2565.      Ignore changes that just insert or delete blank lines.  *Note
  2566.      Blank Lines::.
  2567.      Change the algorithm to perhaps find a smaller set of changes.
  2568.      This makes `sdiff' slower (sometimes much slower).  *Note diff
  2569.      Performance::.
  2570.      Use heuristics to speed handling of large files that have numerous
  2571.      scattered small changes.  *Note diff Performance::.
  2572. `--expand-tabs'
  2573.      Expand tabs to spaces in the output, to preserve the alignment of
  2574.      tabs in the input files.  *Note Tabs::.
  2575.      Ignore changes in case; consider upper- and lower-case to be the
  2576.      same.  *Note Case Folding::.
  2577. `-I REGEXP'
  2578.      Ignore changes that just insert or delete lines that match REGEXP.
  2579.      *Note Specified Folding::.
  2580. `--ignore-all-space'
  2581.      Ignore white space when comparing lines.  *Note White Space::.
  2582. `--ignore-blank-lines'
  2583.      Ignore changes that just insert or delete blank lines.  *Note
  2584.      Blank Lines::.
  2585. `--ignore-case'
  2586.      Ignore changes in case; consider upper- and lower-case to be the
  2587.      same.  *Note Case Folding::.
  2588. `--ignore-matching-lines=REGEXP'
  2589.      Ignore changes that just insert or delete lines that match REGEXP.
  2590.      *Note Specified Folding::.
  2591. `--ignore-space-change'
  2592.      Ignore changes in amount of white space.  *Note White Space::.
  2593. `--left-column'
  2594.      Print only the left column of two common lines.  *Note Side by
  2595.      Side Format::.
  2596. `--minimal'
  2597.      Change the algorithm to perhaps find a smaller set of changes.
  2598.      This makes `sdiff' slower (sometimes much slower).  *Note diff
  2599.      Performance::.
  2600. `-o FILE'
  2601. `--output=FILE'
  2602.      Put merged output into FILE.  This option is required for merging.
  2603. `--suppress-common-lines'
  2604.      Do not print common lines.  *Note Side by Side Format::.
  2605. `--speed-large-files'
  2606.      Use heuristics to speed handling of large files that have numerous
  2607.      scattered small changes.  *Note diff Performance::.
  2608.      Expand tabs to spaces in the output, to preserve the alignment of
  2609.      tabs in the input files.  *Note Tabs::.
  2610. `--text'
  2611.      Treat all files as text and compare them line-by-line, even if they
  2612.      do not appear to be text.  *Note Binary::.
  2613. `--version'
  2614.      Output the version number of `sdiff'.
  2615. `-w COLUMNS'
  2616. `--width=COLUMNS'
  2617.      Use an output width of COLUMNS.  *Note Side by Side Format::.
  2618.      Note that for historical reasons, this option is `-W' in `diff',
  2619.      `-w' in `sdiff'.
  2620.      Ignore horizontal white space when comparing lines.  *Note White
  2621.      Space::.  Note that for historical reasons, this option is `-w' in
  2622.      `diff', `-W' in `sdiff'.
  2623. File: diff.info,  Node: Incomplete Lines,  Next: Projects,  Prev: Invoking sdiff,  Up: Top
  2624. Incomplete Lines
  2625. ****************
  2626.    When an input file ends in a non-newline character, its last line is
  2627. called an "incomplete line" because its last character is not a
  2628. newline.  All other lines are called "full lines" and end in a newline
  2629. character.  Incomplete lines do not match full lines unless differences
  2630. in blank lines are ignored (*note Blank Lines::.).
  2631.    An incomplete line is normally distinguished on output from a full
  2632. line by a following line that starts with `\'.  However, the RCS format
  2633. (*note RCS::.) outputs the incomplete line as-is, without any trailing
  2634. newline or following line.  The side by side format normally represents
  2635. incomplete lines as-is, but in some cases uses a `\' or `/' gutter
  2636. marker; *Note Side by Side::.  The if-then-else line format preserves a
  2637. line's incompleteness with `%L', and discards the newline with `%l';
  2638. *Note Line Formats::.  Finally, with the `ed' and forward `ed' output
  2639. formats (*note Output Formats::.) `diff' cannot represent an incomplete
  2640. line, so it pretends there was a newline and reports an error.
  2641.    For example, suppose `F' and `G' are one-byte files that contain
  2642. just `f' and `g', respectively.  Then `diff F G' outputs
  2643.      1c1
  2644.      < f
  2645.      \ No newline at end of file
  2646.      ---
  2647.      > g
  2648.      \ No newline at end of file
  2649. (The exact message may differ in non-English locales.) `diff -n F G'
  2650. outputs the following without a trailing newline:
  2651.      d1 1
  2652.      a1 1
  2653.      g
  2654.    `diff -e F G' reports two errors and outputs the following:
  2655.      1c
  2656.      g
  2657.      .
  2658. File: diff.info,  Node: Projects,  Next: Concept Index,  Prev: Incomplete Lines,  Up: Top
  2659. Future Projects
  2660. ***************
  2661.    Here are some ideas for improving GNU `diff' and `patch'.  The GNU
  2662. project has identified some improvements as potential programming
  2663. projects for volunteers.  You can also help by reporting any bugs that
  2664. you find.
  2665.    If you are a programmer and would like to contribute something to the
  2666. GNU project, please consider volunteering for one of these projects.  If
  2667. you are seriously contemplating work, please write to
  2668. `gnu@prep.ai.mit.edu' to coordinate with other volunteers.
  2669. * Menu:
  2670. * Shortcomings::    Suggested projects for improvements.
  2671. * Bugs::        Reporting bugs.
  2672. File: diff.info,  Node: Shortcomings,  Next: Bugs,  Up: Projects
  2673. Suggested Projects for Improving GNU `diff' and `patch'
  2674. =======================================================
  2675.    One should be able to use GNU `diff' to generate a patch from any
  2676. pair of directory trees, and given the patch and a copy of one such
  2677. tree, use `patch' to generate a faithful copy of the other.
  2678. Unfortunately, some changes to directory trees cannot be expressed using
  2679. current patch formats; also, `patch' does not handle some of the
  2680. existing formats.  These shortcomings motivate the following suggested
  2681. projects.
  2682. * Menu:
  2683. * Changing Structure::    Handling changes to the directory structure.
  2684. * Special Files::    Handling symbolic links, device special files, etc.
  2685. * Unusual File Names::    Handling file names that contain unusual characters.
  2686. * Arbitrary Limits::    Patching non-text files.
  2687. * Large Files::        Handling files that do not fit in memory.
  2688. * Ignoring Changes::    Ignoring certain changes while showing others.
  2689. File: diff.info,  Node: Changing Structure,  Next: Special Files,  Up: Shortcomings
  2690. Handling Changes to the Directory Structure
  2691. -------------------------------------------
  2692.    `diff' and `patch' do not handle some changes to directory
  2693. structure.  For example, suppose one directory tree contains a directory
  2694. named `D' with some subsidiary files, and another contains a file with
  2695. the same name `D'.  `diff -r' does not output enough information for
  2696. `patch' to transform the the directory subtree into the file.
  2697.    There should be a way to specify that a file has been deleted without
  2698. having to include its entire contents in the patch file.  There should
  2699. also be a way to tell `patch' that a file was renamed, even if there is
  2700. no way for `diff' to generate such information.
  2701.    These problems can be fixed by extending the `diff' output format to
  2702. represent changes in directory structure, and extending `patch' to
  2703. understand these extensions.
  2704. File: diff.info,  Node: Special Files,  Next: Unusual File Names,  Prev: Changing Structure,  Up: Shortcomings
  2705. Files that are Neither Directories Nor Regular Files
  2706. ----------------------------------------------------
  2707.    Some files are neither directories nor regular files: they are
  2708. unusual files like symbolic links, device special files, named pipes,
  2709. and sockets.  Currently, `diff' treats symbolic links like regular
  2710. files; it treats other special files like regular files if they are
  2711. specified at the top level, but simply reports their presence when
  2712. comparing directories.  This means that `patch' cannot represent changes
  2713. to such files.  For example, if you change which file a symbolic link
  2714. points to, `diff' outputs the difference between the two files, instead
  2715. of the change to the symbolic link.
  2716.    `diff' should optionally report changes to special files specially,
  2717. and `patch' should be extended to understand these extensions.
  2718. File: diff.info,  Node: Unusual File Names,  Next: Arbitrary Limits,  Prev: Special Files,  Up: Shortcomings
  2719. File Names that Contain Unusual Characters
  2720. ------------------------------------------
  2721.    When a file name contains an unusual character like a newline or
  2722. white space, `diff -r' generates a patch that `patch' cannot parse.
  2723. The problem is with format of `diff' output, not just with `patch',
  2724. because with odd enough file names one can cause `diff' to generate a
  2725. patch that is syntactically correct but patches the wrong files.  The
  2726. format of `diff' output should be extended to handle all possible file
  2727. names.
  2728. File: diff.info,  Node: Arbitrary Limits,  Next: Large Files,  Prev: Unusual File Names,  Up: Shortcomings
  2729. Arbitrary Limits
  2730. ----------------
  2731.    GNU `diff' can analyze files with arbitrarily long lines and files
  2732. that end in incomplete lines.  However, `patch' cannot patch such
  2733. files.  The `patch' internal limits on line lengths should be removed,
  2734. and `patch' should be extended to parse `diff' reports of incomplete
  2735. lines.
  2736. File: diff.info,  Node: Large Files,  Next: Ignoring Changes,  Prev: Arbitrary Limits,  Up: Shortcomings
  2737. Handling Files that Do Not Fit in Memory
  2738. ----------------------------------------
  2739.    `diff' operates by reading both files into memory.  This method
  2740. fails if the files are too large, and `diff' should have a fallback.
  2741.    One way to do this is to scan the files sequentially to compute hash
  2742. codes of the lines and put the lines in equivalence classes based only
  2743. on hash code.  Then compare the files normally.  This does produce some
  2744. false matches.
  2745.    Then scan the two files sequentially again, checking each match to
  2746. see whether it is real.  When a match is not real, mark both the
  2747. "matching" lines as changed.  Then build an edit script as usual.
  2748.    The output routines would have to be changed to scan the files
  2749. sequentially looking for the text to print.
  2750. File: diff.info,  Node: Ignoring Changes,  Prev: Large Files,  Up: Shortcomings
  2751. Ignoring Certain Changes
  2752. ------------------------
  2753.    It would be nice to have a feature for specifying two strings, one in
  2754. FROM-FILE and one in TO-FILE, which should be considered to match.
  2755. Thus, if the two strings are `foo' and `bar', then if two lines differ
  2756. only in that `foo' in file 1 corresponds to `bar' in file 2, the lines
  2757. are treated as identical.
  2758.    It is not clear how general this feature can or should be, or what
  2759. syntax should be used for it.
  2760. File: diff.info,  Node: Bugs,  Prev: Shortcomings,  Up: Projects
  2761. Reporting Bugs
  2762. ==============
  2763.    If you think you have found a bug in GNU `cmp', `diff', `diff3',
  2764. `sdiff', or `patch', please report it by electronic mail to
  2765. `bug-gnu-utils@prep.ai.mit.edu'.  Send as precise a description of the
  2766. problem as you can, including sample input files that produce the bug,
  2767. if applicable.
  2768.    Because Larry Wall has not released a new version of `patch' since
  2769. mid 1988 and the GNU version of `patch' has been changed since then,
  2770. please send bug reports for `patch' by electronic mail to both
  2771. `bug-gnu-utils@prep.ai.mit.edu' and `lwall@netlabs.com'.
  2772. File: diff.info,  Node: Concept Index,  Prev: Projects,  Up: Top
  2773. Concept Index
  2774. *************
  2775. * Menu:
  2776. * cmp invocation:                       Invoking cmp.
  2777. * cmp options:                          cmp Options.
  2778. * diff3 hunks:                          diff3 Hunks.
  2779. * diff3 invocation:                     Invoking diff3.
  2780. * diff3 options:                        diff3 Options.
  2781. * diff3 sample input:                   Sample diff3 Input.
  2782. * diff invocation:                      Invoking diff.
  2783. * diff options:                         diff Options.
  2784. * diff sample input:                    Sample diff Input.
  2785. * ed script output format:              ed Scripts.
  2786. * ifdef output format:                  If-then-else.
  2787. * patch input format:                   patch Input.
  2788. * patch invocation:                     Invoking patch.
  2789. * patch messages and questions:         patch Messages.
  2790. * patch options:                        patch Options.
  2791. * sdiff invocation:                     Invoking sdiff.
  2792. * sdiff options:                        sdiff Options.
  2793. * sdiff output format:                  sdiff Option Summary.
  2794. * ! output format:                      Context.
  2795. * +- output format:                     Unified Format.
  2796. * <<<<<<< for marking conflicts:        Marking Conflicts.
  2797. * < output format:                      Normal.
  2798. * aligning tabstops:                    Tabs.
  2799. * alternate file names:                 Alternate Names.
  2800. * backup file names:                    Backups.
  2801. * binary file diff:                     Binary.
  2802. * binary file patching:                 Arbitrary Limits.
  2803. * blank and tab difference suppression: White Space.
  2804. * blank line difference suppression:    Blank Lines.
  2805. * brief difference reports:             Brief.
  2806. * bug reports:                          Bugs.
  2807. * C function headings:                  C Function Headings.
  2808. * C if-then-else output format:         If-then-else.
  2809. * case difference suppression:          Case Folding.
  2810. * columnar output:                      Side by Side.
  2811. * comparing three files:                Comparing Three Files.
  2812. * conflict:                             diff3 Merging.
  2813. * conflict marking:                     Marking Conflicts.
  2814. * context output format:                Context.
  2815. * diagnostics from patch:               patch Messages.
  2816. * diff merging:                         Interactive Merging.
  2817. * directories and patch:                patch Directories.
  2818. * directory structure changes:          Changing Structure.
  2819. * empty files, removing:                Empty Files.
  2820. * file name alternates:                 Alternate Names.
  2821. * file names with unusual characters:   Unusual File Names.
  2822. * format of diff3 output:               Comparing Three Files.
  2823. * format of diff output:                Output Formats.
  2824. * formats for if-then-else line groups: Line Group Formats.
  2825. * forward ed script output format:      Forward ed.
  2826. * full lines:                           Incomplete Lines.
  2827. * function headings, C:                 C Function Headings.
  2828. * fuzz factor when patching:            Inexact.
  2829. * headings:                             Sections.
  2830. * hunks:                                Hunks.
  2831. * hunks for diff3:                      diff3 Hunks.
  2832. * if-then-else output format:           If-then-else.
  2833. * imperfect patch application:          Imperfect.
  2834. * incomplete line merging:              Merging Incomplete Lines.
  2835. * incomplete lines:                     Incomplete Lines.
  2836. * inexact patches:                      Inexact.
  2837. * interactive merging:                  Interactive Merging.
  2838. * introduction:                         Comparison.
  2839. * invoking cmp:                         Invoking cmp.
  2840. * invoking diff3:                       Invoking diff3.
  2841. * invoking diff:                        Invoking diff.
  2842. * invoking patch:                       Invoking patch.
  2843. * invoking sdiff:                       Invoking sdiff.
  2844. * large files:                          Large Files.
  2845. * line formats:                         Line Formats.
  2846. * line group formats:                   Line Group Formats.
  2847. * merge commands:                       Merge Commands.
  2848. * merged diff3 format:                  Bypassing ed.
  2849. * merged output format:                 If-then-else.
  2850. * merging from a common ancestor:       diff3 Merging.
  2851. * merging interactively:                Merge Commands.
  2852. * messages from patch:                  patch Messages.
  2853. * multiple patches:                     Multiple Patches.
  2854. * newline treatment by diff:            Incomplete Lines.
  2855. * normal output format:                 Normal.
  2856. * options for cmp:                      cmp Options.
  2857. * options for diff3:                    diff3 Options.
  2858. * options for diff:                     diff Options.
  2859. * options for patch:                    patch Options.
  2860. * options for sdiff:                    sdiff Options.
  2861. * output formats:                       Output Formats.
  2862. * overlap:                              diff3 Merging.
  2863. * overlapping change, selection of:     Which Changes.
  2864. * overview of diff and patch:           Overview.
  2865. * paginating diff output:               Pagination.
  2866. * patch making tips:                    Making Patches.
  2867. * patching directories:                 patch Directories.
  2868. * performance of diff:                  diff Performance.
  2869. * projects for directories:             Shortcomings.
  2870. * RCS script output format:             RCS.
  2871. * regular expression matching headings: Specified Headings.
  2872. * regular expression suppression:       Specified Folding.
  2873. * reject file names:                    Rejects.
  2874. * removing empty files:                 Empty Files.
  2875. * reporting bugs:                       Bugs.
  2876. * reversed patches:                     Reversed Patches.
  2877. * sample input for diff3:               Sample diff3 Input.
  2878. * sample input for diff:                Sample diff Input.
  2879. * script output formats:                Scripts.
  2880. * section headings:                     Sections.
  2881. * side by side:                         Side by Side.
  2882. * side by side format:                  Side by Side Format.
  2883. * special files:                        Special Files.
  2884. * specified headings:                   Specified Headings.
  2885. * summarizing which files differ:       Brief.
  2886. * System V diff3 compatibility:         Saving the Changed File.
  2887. * tab and blank difference suppression: White Space.
  2888. * tabstop alignment:                    Tabs.
  2889. * text versus binary diff:              Binary.
  2890. * tips for patch making:                Making Patches.
  2891. * two-column output:                    Side by Side.
  2892. * unified output format:                Unified Format.
  2893. * unmerged change:                      Which Changes.
  2894. * white space in patches:               Changed White Space.
  2895. Tag Table:
  2896. Node: Top
  2897. Node: Overview
  2898. Node: Comparison
  2899. Node: Hunks
  2900. Node: White Space
  2901. Node: Blank Lines
  2902. 10808
  2903. Node: Case Folding
  2904. 11572
  2905. Node: Specified Folding
  2906. 11985
  2907. Node: Brief
  2908. 13075
  2909. Node: Binary
  2910. 14326
  2911. Node: Output Formats
  2912. 16837
  2913. Node: Sample diff Input
  2914. 17529
  2915. Node: Normal
  2916. 19022
  2917. Node: Detailed Normal
  2918. 19951
  2919. Node: Example Normal
  2920. 21676
  2921. Node: Context
  2922. 22399
  2923. Node: Context Format
  2924. 23947
  2925. Node: Detailed Context
  2926. 24720
  2927. Node: Example Context
  2928. 26276
  2929. Node: Less Context
  2930. 27769
  2931. Node: Unified Format
  2932. 28901
  2933. Node: Detailed Unified
  2934. 29680
  2935. Node: Example Unified
  2936. 30664
  2937. Node: Sections
  2938. 31663
  2939. Node: Specified Headings
  2940. 32407
  2941. Node: C Function Headings
  2942. 33954
  2943. Node: Alternate Names
  2944. 34698
  2945. Node: Side by Side
  2946. 35595
  2947. Node: Side by Side Format
  2948. 37735
  2949. Node: Example Side by Side
  2950. 38632
  2951. Node: Scripts
  2952. 39959
  2953. Node: ed Scripts
  2954. 40357
  2955. Node: Detailed ed
  2956. 41552
  2957. Node: Example ed
  2958. 43293
  2959. Node: Forward ed
  2960. 43731
  2961. Node: RCS
  2962. 44493
  2963. Node: If-then-else
  2964. 45703
  2965. Node: Line Group Formats
  2966. 47360
  2967. Node: Line Formats
  2968. 53042
  2969. Node: Detailed If-then-else
  2970. 56304
  2971. Node: Example If-then-else
  2972. 58205
  2973. Node: Comparing Directories
  2974. 59257
  2975. Node: Adjusting Output
  2976. 62372
  2977. Node: Tabs
  2978. 62791
  2979. Node: Pagination
  2980. 64313
  2981. Node: diff Performance
  2982. 64732
  2983. Node: Comparing Three Files
  2984. 66678
  2985. Node: Sample diff3 Input
  2986. 67539
  2987. Node: Detailed diff3 Normal
  2988. 68488
  2989. Node: diff3 Hunks
  2990. 70268
  2991. Node: Example diff3 Normal
  2992. 71554
  2993. Node: diff3 Merging
  2994. 72578
  2995. Node: Which Changes
  2996. 74788
  2997. Node: Marking Conflicts
  2998. 76194
  2999. Node: Bypassing ed
  3000. 78651
  3001. Node: Merging Incomplete Lines
  3002. 80006
  3003. Node: Saving the Changed File
  3004. 80723
  3005. Node: Interactive Merging
  3006. 81333
  3007. Node: sdiff Option Summary
  3008. 82031
  3009. Node: Merge Commands
  3010. 83131
  3011. Node: Merging with patch
  3012. 84267
  3013. Node: patch Input
  3014. 86374
  3015. Node: Imperfect
  3016. 87037
  3017. Node: Changed White Space
  3018. 87774
  3019. Node: Reversed Patches
  3020. 88525
  3021. Node: Inexact
  3022. 90110
  3023. Node: Empty Files
  3024. 93464
  3025. Node: Multiple Patches
  3026. 94028
  3027. Node: patch Messages
  3028. 95340
  3029. Node: Making Patches
  3030. 97161
  3031. Node: Invoking cmp
  3032. 100459
  3033. Node: cmp Options
  3034. 101063
  3035. Node: Invoking diff
  3036. 102493
  3037. Node: diff Options
  3038. 103959
  3039. Node: Invoking diff3
  3040. 114492
  3041. Node: diff3 Options
  3042. 115123
  3043. Node: Invoking patch
  3044. 118725
  3045. Node: patch Directories
  3046. 120659
  3047. Node: Backups
  3048. 122453
  3049. Node: Rejects
  3050. 125000
  3051. Node: patch Options
  3052. 125550
  3053. Node: Invoking sdiff
  3054. 130407
  3055. Node: sdiff Options
  3056. 131517
  3057. Node: Incomplete Lines
  3058. 134834
  3059. Node: Projects
  3060. 136457
  3061. Node: Shortcomings
  3062. 137151
  3063. Node: Changing Structure
  3064. 138146
  3065. Node: Special Files
  3066. 139094
  3067. Node: Unusual File Names
  3068. 140040
  3069. Node: Arbitrary Limits
  3070. 140662
  3071. Node: Large Files
  3072. 141091
  3073. Node: Ignoring Changes
  3074. 141963
  3075. Node: Bugs
  3076. 142507
  3077. Node: Concept Index
  3078. 143152
  3079. End Tag Table
  3080.