home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rcs57pc1.zip / doc / diff.info (.txt) < prev    next >
GNU Info File  |  1996-02-13  |  153KB  |  3,094 lines

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