Upgrade diffutils from 2.8.7 to 3.0 on the vendor branch
[dragonfly.git] / contrib / diffutils / doc / diff.info
1 This is diff.info, produced by makeinfo version 4.13 from diff.texi.
2
3 This manual is for GNU Diffutils (version 3.0, 15 April 2010), and
4 documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for
5 showing the differences between files and the GNU `patch' command for
6 using their output to update files.
7
8    Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2010 Free
9 Software Foundation, Inc.
10
11      Permission is granted to copy, distribute and/or modify this
12      document under the terms of the GNU Free Documentation License,
13      Version 1.3 or any later version published by the Free Software
14      Foundation; with no Invariant Sections, with the Front-Cover texts
15      being "A GNU Manual," and with the Back-Cover Texts as in (a)
16      below.  A copy of the license is included in the section entitled
17      "GNU Free Documentation License."
18
19      (a) The FSF's Back-Cover Text is: "You have the freedom to copy
20      and modify this GNU manual.  Buying copies from the FSF supports
21      it in developing GNU and promoting software freedom."
22
23 INFO-DIR-SECTION Individual utilities
24 START-INFO-DIR-ENTRY
25 * cmp: (diff)Invoking cmp.                      Compare 2 files byte by byte.
26 * diff: (diff)Invoking diff.                    Compare 2 files line by line.
27 * diff3: (diff)Invoking diff3.                  Compare 3 files line by line.
28 * patch: (diff)Invoking patch.                  Apply a patch to a file.
29 * sdiff: (diff)Invoking sdiff.                  Merge 2 files side-by-side.
30 END-INFO-DIR-ENTRY
31
32 INFO-DIR-SECTION Text creation and manipulation
33 START-INFO-DIR-ENTRY
34 * Diff: (diff).                 Comparing and merging files.
35 END-INFO-DIR-ENTRY
36
37 \1f
38 File: diff.info,  Node: Top,  Next: Overview,  Up: (dir)
39
40 Comparing and Merging Files
41 ***************************
42
43 This manual is for GNU Diffutils (version 3.0, 15 April 2010), and
44 documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for
45 showing the differences between files and the GNU `patch' command for
46 using their output to update files.
47
48    Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2010 Free
49 Software Foundation, Inc.
50
51      Permission is granted to copy, distribute and/or modify this
52      document under the terms of the GNU Free Documentation License,
53      Version 1.3 or any later version published by the Free Software
54      Foundation; with no Invariant Sections, with the Front-Cover texts
55      being "A GNU Manual," and with the Back-Cover Texts as in (a)
56      below.  A copy of the license is included in the section entitled
57      "GNU Free Documentation License."
58
59      (a) The FSF's Back-Cover Text is: "You have the freedom to copy
60      and modify this GNU manual.  Buying copies from the FSF supports
61      it in developing GNU and promoting software freedom."
62
63 * Menu:
64
65 * Overview::              Preliminary information.
66 * Comparison::            What file comparison means.
67
68 * Output Formats::        Formats for two-way difference reports.
69 * Incomplete Lines::      Lines that lack trailing newlines.
70 * Comparing Directories:: Comparing files and directories.
71 * Adjusting Output::      Making `diff' output prettier.
72 * diff Performance::      Making `diff' smarter or faster.
73
74 * Comparing Three Files:: Formats for three-way difference reports.
75 * diff3 Merging::         Merging from a common ancestor.
76
77 * Interactive Merging::   Interactive merging with `sdiff'.
78
79 * Merging with patch::    Using `patch' to change old files into new ones.
80 * Making Patches::        Tips for making and using patch distributions.
81
82 * Invoking cmp::          Compare two files byte by byte.
83 * Invoking diff::         Compare two files line by line.
84 * Invoking diff3::        Compare three files line by line.
85 * Invoking patch::        Apply a diff file to an original.
86 * Invoking sdiff::        Side-by-side merge of file differences.
87
88 * Standards conformance:: Conformance to the POSIX standard.
89 * Projects::              If you've found a bug or other shortcoming.
90
91 * Copying This Manual::   How to make copies of this manual.
92 * Translations::          Available translations of this manual.
93 * Index::                 Index.
94
95 \1f
96 File: diff.info,  Node: Overview,  Next: Comparison,  Prev: Top,  Up: Top
97
98 Overview
99 ********
100
101 Computer users often find occasion to ask how two files differ.  Perhaps
102 one file is a newer version of the other file.  Or maybe the two files
103 started out as identical copies but were changed by different people.
104
105    You can use the `diff' command to show differences between two
106 files, or each corresponding file in two directories.  `diff' outputs
107 differences between files line by line in any of several formats,
108 selectable by command line options.  This set of differences is often
109 called a "diff" or "patch".  For files that are identical, `diff'
110 normally produces no output; for binary (non-text) files, `diff'
111 normally reports only that they are different.
112
113    You can use the `cmp' command to show the byte and line numbers
114 where two files differ.  `cmp' can also show all the bytes that differ
115 between the two files, side by side.  A way to compare two files
116 character by character is the Emacs command `M-x compare-windows'.
117 *Note Other Window: (emacs)Other Window, for more information on that
118 command.
119
120    You can use the `diff3' command to show differences among three
121 files.  When two people have made independent changes to a common
122 original, `diff3' can report the differences between the original and
123 the two changed versions, and can produce a merged file that contains
124 both persons' changes together with warnings about conflicts.
125
126    You can use the `sdiff' command to merge two files interactively.
127
128    You can use the set of differences produced by `diff' to distribute
129 updates to text files (such as program source code) to other people.
130 This method is especially useful when the differences are small compared
131 to the complete files.  Given `diff' output, you can use the `patch'
132 program to update, or "patch", a copy of the file.  If you think of
133 `diff' as subtracting one file from another to produce their
134 difference, you can think of `patch' as adding the difference to one
135 file to reproduce the other.
136
137    This manual first concentrates on making diffs, and later shows how
138 to use diffs to update files.
139
140    GNU `diff' was written by Paul Eggert, Mike Haertel, David Hayes,
141 Richard Stallman, and Len Tower.  Wayne Davison designed and
142 implemented the unified output format.  The basic algorithm is described
143 by Eugene W. Myers in "An O(ND) Difference Algorithm and its
144 Variations", `Algorithmica' Vol. 1 No. 2, 1986, pp. 251-266; and in "A
145 File Comparison Program", Webb Miller and Eugene W. Myers,
146 `Software--Practice and Experience' Vol. 15 No. 11, 1985, pp. 1025-1040.
147 The algorithm was independently discovered as described by E. Ukkonen in
148 "Algorithms for Approximate String Matching", `Information and Control'
149 Vol. 64, 1985, pp. 100-118.  Unless the `--minimal' option is used,
150 `diff' uses a heuristic by Paul Eggert that limits the cost to O(N^1.5
151 log N) at the price of producing suboptimal output for large inputs
152 with many differences.  Related algorithms are surveyed by Alfred V.
153 Aho in section 6.3 of "Algorithms for Finding Patterns in Strings",
154 `Handbook of Theoretical Computer Science' (Jan Van Leeuwen, ed.), Vol.
155 A, `Algorithms and Complexity', Elsevier/MIT Press, 1990, pp. 255-300.
156
157    GNU `diff3' was written by Randy Smith.  GNU `sdiff' was written by
158 Thomas Lord.  GNU `cmp' was written by Torbjo"rn Granlund and David
159 MacKenzie.
160
161    GNU `patch' was written mainly by Larry Wall and Paul Eggert;
162 several GNU enhancements were contributed by Wayne Davison and David
163 MacKenzie.  Parts of this manual are adapted from a manual page written
164 by Larry Wall, with his permission.
165
166 \1f
167 File: diff.info,  Node: Comparison,  Next: Output Formats,  Prev: Overview,  Up: Top
168
169 1 What Comparison Means
170 ***********************
171
172 There are several ways to think about the differences between two files.
173 One way to think of the differences is as a series of lines that were
174 deleted from, inserted in, or changed in one file to produce the other
175 file.  `diff' compares two files line by line, finds groups of lines
176 that differ, and reports each group of differing lines.  It can report
177 the differing lines in several formats, which have different purposes.
178
179    GNU `diff' can show whether files are different without detailing
180 the differences.  It also provides ways to suppress certain kinds of
181 differences that are not important to you.  Most commonly, such
182 differences are changes in the amount of white space between words or
183 lines.  `diff' also provides ways to suppress differences in alphabetic
184 case or in lines that match a regular expression that you provide.
185 These options can accumulate; for example, you can ignore changes in
186 both white space and alphabetic case.
187
188    Another way to think of the differences between two files is as a
189 sequence of pairs of bytes that can be either identical or different.
190 `cmp' reports the differences between two files byte by byte, instead
191 of line by line.  As a result, it is often more useful than `diff' for
192 comparing binary files.  For text files, `cmp' is useful mainly when
193 you want to know only whether two files are identical, or whether one
194 file is a prefix of the other.
195
196    To illustrate the effect that considering changes byte by byte can
197 have compared with considering them line by line, think of what happens
198 if a single newline character is added to the beginning of a file.  If
199 that file is then compared with an otherwise identical file that lacks
200 the newline at the beginning, `diff' will report that a blank line has
201 been added to the file, while `cmp' will report that almost every byte
202 of the two files differs.
203
204    `diff3' normally compares three input files line by line, finds
205 groups of lines that differ, and reports each group of differing lines.
206 Its output is designed to make it easy to inspect two different sets of
207 changes to the same file.
208
209 * Menu:
210
211 * Hunks::             Groups of differing lines.
212 * White Space::       Suppressing differences in white space.
213 * Blank Lines::       Suppressing differences whose lines are all blank.
214 * Specified Lines::   Suppressing differences whose lines all match a pattern.
215 * Case Folding::      Suppressing differences in alphabetic case.
216 * Brief::             Summarizing which files are different.
217 * Binary::            Comparing binary files or forcing text comparisons.
218
219 \1f
220 File: diff.info,  Node: Hunks,  Next: White Space,  Up: Comparison
221
222 1.1 Hunks
223 =========
224
225 When comparing two files, `diff' finds sequences of lines common to
226 both files, interspersed with groups of differing lines called "hunks".
227 Comparing two identical files yields one sequence of common lines and
228 no hunks, because no lines differ.  Comparing two entirely different
229 files yields no common lines and one large hunk that contains all lines
230 of both files.  In general, there are many ways to match up lines
231 between two given files.  `diff' tries to minimize the total hunk size
232 by finding large sequences of common lines interspersed with small
233 hunks of differing lines.
234
235    For example, suppose the file `F' contains the three lines `a', `b',
236 `c', and the file `G' contains the same three lines in reverse order
237 `c', `b', `a'.  If `diff' finds the line `c' as common, then the command
238 `diff F G' produces this output:
239
240      1,2d0
241      < a
242      < b
243      3a2,3
244      > b
245      > a
246
247 But if `diff' notices the common line `b' instead, it produces this
248 output:
249
250      1c1
251      < a
252      ---
253      > c
254      3c3
255      < c
256      ---
257      > a
258
259 It is also possible to find `a' as the common line.  `diff' does not
260 always find an optimal matching between the files; it takes shortcuts
261 to run faster.  But its output is usually close to the shortest
262 possible.  You can adjust this tradeoff with the `-d' or `--minimal'
263 option (*note diff Performance::).
264
265 \1f
266 File: diff.info,  Node: White Space,  Next: Blank Lines,  Prev: Hunks,  Up: Comparison
267
268 1.2 Suppressing Differences in Blank and Tab Spacing
269 ====================================================
270
271 The `-E' or `--ignore-tab-expansion' option ignores the distinction
272 between tabs and spaces on input.  A tab is considered to be equivalent
273 to the number of spaces to the next tab stop (*note Tabs::).
274
275    The `-b' or `--ignore-space-change' option is stronger.  It ignores
276 white space at line end, and considers all other sequences of one or
277 more white space characters within a line to be equivalent.  With this
278 option, `diff' considers the following two lines to be equivalent,
279 where `$' denotes the line end:
280
281      Here lyeth  muche rychnesse  in lytell space.   -- John Heywood$
282      Here lyeth muche rychnesse in lytell space. -- John Heywood   $
283
284    The `-w' or `--ignore-all-space' option is stronger still.  It
285 ignores differences even if one line has white space where the other
286 line has none.  "White space" characters include tab, vertical tab,
287 form feed, carriage return, and space; some locales may define
288 additional characters to be white space.  With this option, `diff'
289 considers the following two lines to be equivalent, where `$' denotes
290 the line end and `^M' denotes a carriage return:
291
292      Here lyeth  muche  rychnesse in lytell space.--  John Heywood$
293        He relyeth much erychnes  seinly tells pace.  --John Heywood   ^M$
294
295    For many other programs newline is also a white space character, but
296 `diff' is a line-oriented program and a newline character always ends a
297 line.  Hence the `-w' or `--ignore-all-space' option does not ignore
298 newline-related changes; it ignores only other white space changes.
299
300 \1f
301 File: diff.info,  Node: Blank Lines,  Next: Specified Lines,  Prev: White Space,  Up: Comparison
302
303 1.3 Suppressing Differences Whose Lines Are All Blank
304 =====================================================
305
306 The `-B' or `--ignore-blank-lines' option ignores changes that consist
307 entirely of blank lines.  With this option, for example, a file
308 containing
309      1.  A point is that which has no part.
310
311      2.  A line is breadthless length.
312      -- Euclid, The Elements, I
313    is considered identical to a file containing
314      1.  A point is that which has no part.
315      2.  A line is breadthless length.
316
317
318      -- Euclid, The Elements, I
319
320    Normally this option affects only lines that are completely empty,
321 but if you also specify the `-b' or `--ignore-space-change' option, or
322 the `-w' or `--ignore-all-space' option, lines are also affected if
323 they look empty but contain white space.  In other words, `-B' is
324 equivalent to `-I '^$'' by default, but it is equivalent to `-I
325 '^[[:space:]]*$'' if `-b' or `-w' is also specified.
326
327 \1f
328 File: diff.info,  Node: Specified Lines,  Next: Case Folding,  Prev: Blank Lines,  Up: Comparison
329
330 1.4 Suppressing Differences Whose Lines All Match a Regular Expression
331 ======================================================================
332
333 To ignore insertions and deletions of lines that match a `grep'-style
334 regular expression, use the `-I REGEXP' or
335 `--ignore-matching-lines=REGEXP' option.  You should escape regular
336 expressions that contain shell metacharacters to prevent the shell from
337 expanding them.  For example, `diff -I '^[[:digit:]]'' ignores all
338 changes to lines beginning with a digit.
339
340    However, `-I' only ignores the insertion or deletion of lines that
341 contain the regular expression if every changed line in the hunk--every
342 insertion and every deletion--matches the regular expression.  In other
343 words, for each nonignorable change, `diff' prints the complete set of
344 changes in its vicinity, including the ignorable ones.
345
346    You can specify more than one regular expression for lines to ignore
347 by using more than one `-I' option.  `diff' tries to match each line
348 against each regular expression.
349
350 \1f
351 File: diff.info,  Node: Case Folding,  Next: Brief,  Prev: Specified Lines,  Up: Comparison
352
353 1.5 Suppressing Case Differences
354 ================================
355
356 GNU `diff' can treat lower case letters as equivalent to their upper
357 case counterparts, so that, for example, it considers `Funky Stuff',
358 `funky STUFF', and `fUNKy stuFf' to all be the same.  To request this,
359 use the `-i' or `--ignore-case' option.
360
361 \1f
362 File: diff.info,  Node: Brief,  Next: Binary,  Prev: Case Folding,  Up: Comparison
363
364 1.6 Summarizing Which Files Differ
365 ==================================
366
367 When you only want to find out whether files are different, and you
368 don't care what the differences are, you can use the summary output
369 format.  In this format, instead of showing the differences between the
370 files, `diff' simply reports whether files differ.  The `-q' or
371 `--brief' option selects this output format.
372
373    This format is especially useful when comparing the contents of two
374 directories.  It is also much faster than doing the normal line by line
375 comparisons, because `diff' can stop analyzing the files as soon as it
376 knows that there are any differences.
377
378    You can also get a brief indication of whether two files differ by
379 using `cmp'.  For files that are identical, `cmp' produces no output.
380 When the files differ, by default, `cmp' outputs the byte and line
381 number where the first difference occurs, or reports that one file is a
382 prefix of the other.  You can use the `-s', `--quiet', or `--silent'
383 option to suppress that information, so that `cmp' produces no output
384 and reports whether the files differ using only its exit status (*note
385 Invoking cmp::).
386
387    Unlike `diff', `cmp' cannot compare directories; it can only compare
388 two files.
389
390 \1f
391 File: diff.info,  Node: Binary,  Prev: Brief,  Up: Comparison
392
393 1.7 Binary Files and Forcing Text Comparisons
394 =============================================
395
396 If `diff' thinks that either of the two files it is comparing is binary
397 (a non-text file), it normally treats that pair of files much as if the
398 summary output format had been selected (*note Brief::), and reports
399 only that the binary files are different.  This is because line by line
400 comparisons are usually not meaningful for binary files.
401
402    `diff' determines whether a file is text or binary by checking the
403 first few bytes in the file; the exact number of bytes is system
404 dependent, but it is typically several thousand.  If every byte in that
405 part of the file is non-null, `diff' considers the file to be text;
406 otherwise it considers the file to be binary.
407
408    Sometimes you might want to force `diff' to consider files to be
409 text.  For example, you might be comparing text files that contain null
410 characters; `diff' would erroneously decide that those are non-text
411 files.  Or you might be comparing documents that are in a format used
412 by a word processing system that uses null characters to indicate
413 special formatting.  You can force `diff' to consider all files to be
414 text files, and compare them line by line, by using the `-a' or
415 `--text' option.  If the files you compare using this option do not in
416 fact contain text, they will probably contain few newline characters,
417 and the `diff' output will consist of hunks showing differences between
418 long lines of whatever characters the files contain.
419
420    You can also force `diff' to report only whether files differ (but
421 not how).  Use the `-q' or `--brief' option for this.
422
423    Normally, differing binary files count as trouble because the
424 resulting `diff' output does not capture all the differences.  This
425 trouble causes `diff' to exit with status 2.  However, this trouble
426 cannot occur with the `-a' or `--text' option, or with the `-q' or
427 `--brief' option, as these options both cause `diff' to generate a form
428 of output that represents differences as requested.
429
430    In operating systems that distinguish between text and binary files,
431 `diff' normally reads and writes all data as text.  Use the `--binary'
432 option to force `diff' to read and write binary data instead.  This
433 option has no effect on a POSIX-compliant system like GNU or
434 traditional Unix.  However, many personal computer operating systems
435 represent the end of a line with a carriage return followed by a
436 newline.  On such systems, `diff' normally ignores these carriage
437 returns on input and generates them at the end of each output line, but
438 with the `--binary' option `diff' treats each carriage return as just
439 another input character, and does not generate a carriage return at the
440 end of each output line.  This can be useful when dealing with non-text
441 files that are meant to be interchanged with POSIX-compliant systems.
442
443    The `--strip-trailing-cr' causes `diff' to treat input lines that
444 end in carriage return followed by newline as if they end in plain
445 newline.  This can be useful when comparing text that is imperfectly
446 imported from many personal computer operating systems.  This option
447 affects how lines are read, which in turn affects how they are compared
448 and output.
449
450    If you want to compare two files byte by byte, you can use the `cmp'
451 program with the `-l' or `--verbose' option to show the values of each
452 differing byte in the two files.  With GNU `cmp', you can also use the
453 `-b' or `--print-bytes' option to show the ASCII representation of
454 those bytes.  *Note Invoking cmp::, for more information.
455
456    If `diff3' thinks that any of the files it is comparing is binary (a
457 non-text file), it normally reports an error, because such comparisons
458 are usually not useful.  `diff3' uses the same test as `diff' to decide
459 whether a file is binary.  As with `diff', if the input files contain a
460 few non-text bytes but otherwise are like text files, you can force
461 `diff3' to consider all files to be text files and compare them line by
462 line by using the `-a' or `--text' option.
463
464 \1f
465 File: diff.info,  Node: Output Formats,  Next: Incomplete Lines,  Prev: Comparison,  Up: Top
466
467 2 `diff' Output Formats
468 ***********************
469
470 `diff' has several mutually exclusive options for output format.  The
471 following sections describe each format, illustrating how `diff'
472 reports the differences between two sample input files.
473
474 * Menu:
475
476 * Sample diff Input:: Sample `diff' input files for examples.
477 * Context::           Showing differences with the surrounding text.
478 * Side by Side::      Showing differences in two columns.
479 * Normal::            Showing differences without surrounding text.
480 * Scripts::           Generating scripts for other programs.
481 * If-then-else::      Merging files with if-then-else.
482
483 \1f
484 File: diff.info,  Node: Sample diff Input,  Next: Context,  Up: Output Formats
485
486 2.1 Two Sample Input Files
487 ==========================
488
489 Here are two sample files that we will use in numerous examples to
490 illustrate the output of `diff' and how various options can change it.
491
492    This is the file `lao':
493
494      The Way that can be told of is not the eternal Way;
495      The name that can be named is not the eternal name.
496      The Nameless is the origin of Heaven and Earth;
497      The Named is the mother of all things.
498      Therefore let there always be non-being,
499        so we may see their subtlety,
500      And let there always be being,
501        so we may see their outcome.
502      The two are the same,
503      But after they are produced,
504        they have different names.
505
506    This is the file `tzu':
507
508      The Nameless is the origin of Heaven and Earth;
509      The named is the mother of all things.
510
511      Therefore let there always be non-being,
512        so we may see their subtlety,
513      And let there always be being,
514        so we may see their outcome.
515      The two are the same,
516      But after they are produced,
517        they have different names.
518      They both may be called deep and profound.
519      Deeper and more profound,
520      The door of all subtleties!
521
522    In this example, the first hunk contains just the first two lines of
523 `lao', the second hunk contains the fourth line of `lao' opposing the
524 second and third lines of `tzu', and the last hunk contains just the
525 last three lines of `tzu'.
526
527 \1f
528 File: diff.info,  Node: Context,  Next: Side by Side,  Prev: Sample diff Input,  Up: Output Formats
529
530 2.2 Showing Differences in Their Context
531 ========================================
532
533 Usually, when you are looking at the differences between files, you will
534 also want to see the parts of the files near the lines that differ, to
535 help you understand exactly what has changed.  These nearby parts of the
536 files are called the "context".
537
538    GNU `diff' provides two output formats that show context around the
539 differing lines: "context format" and "unified format".  It can
540 optionally show in which function or section of the file the differing
541 lines are found.
542
543    If you are distributing new versions of files to other people in the
544 form of `diff' output, you should use one of the output formats that
545 show context so that they can apply the diffs even if they have made
546 small changes of their own to the files.  `patch' can apply the diffs
547 in this case by searching in the files for the lines of context around
548 the differing lines; if those lines are actually a few lines away from
549 where the diff says they are, `patch' can adjust the line numbers
550 accordingly and still apply the diff correctly.  *Note Imperfect::, for
551 more information on using `patch' to apply imperfect diffs.
552
553 * Menu:
554
555 * Context Format::  An output format that shows surrounding lines.
556 * Unified Format::  A more compact output format that shows context.
557 * Sections::        Showing which sections of the files differences are in.
558 * Alternate Names:: Showing alternate file names in context headers.
559
560 \1f
561 File: diff.info,  Node: Context Format,  Next: Unified Format,  Up: Context
562
563 2.2.1 Context Format
564 --------------------
565
566 The context output format shows several lines of context around the
567 lines that differ.  It is the standard format for distributing updates
568 to source code.
569
570    To select this output format, use the `-C LINES',
571 `--context[=LINES]', or `-c' option.  The argument LINES that some of
572 these options take is the number of lines of context to show.  If you
573 do not specify LINES, it defaults to three.  For proper operation,
574 `patch' typically needs at least two lines of context.
575
576 * Menu:
577
578 * Example Context::  Sample output in context format.
579 * Less Context::     Another sample with less context.
580 * Detailed Context:: A detailed description of the context output format.
581
582 \1f
583 File: diff.info,  Node: Example Context,  Next: Less Context,  Up: Context Format
584
585 2.2.1.1 An Example of Context Format
586 ....................................
587
588 Here is the output of `diff -c lao tzu' (*note Sample diff Input::, for
589 the complete contents of the two files).  Notice that up to three lines
590 that are not different are shown around each line that is different;
591 they are the context lines.  Also notice that the first two hunks have
592 run together, because their contents overlap.
593
594      *** lao    2002-02-21 23:30:39.942229878 -0800
595      --- tzu    2002-02-21 23:30:50.442260588 -0800
596      ***************
597      *** 1,7 ****
598      - The Way that can be told of is not the eternal Way;
599      - The name that can be named is not the eternal name.
600        The Nameless is the origin of Heaven and Earth;
601      ! The Named is the mother of all things.
602        Therefore let there always be non-being,
603          so we may see their subtlety,
604        And let there always be being,
605      --- 1,6 ----
606        The Nameless is the origin of Heaven and Earth;
607      ! The named is the mother of all things.
608      !
609        Therefore let there always be non-being,
610          so we may see their subtlety,
611        And let there always be being,
612      ***************
613      *** 9,11 ****
614      --- 8,13 ----
615        The two are the same,
616        But after they are produced,
617          they have different names.
618      + They both may be called deep and profound.
619      + Deeper and more profound,
620      + The door of all subtleties!
621
622 \1f
623 File: diff.info,  Node: Less Context,  Next: Detailed Context,  Prev: Example Context,  Up: Context Format
624
625 2.2.1.2 An Example of Context Format with Less Context
626 ......................................................
627
628 Here is the output of `diff -C 1 lao tzu' (*note Sample diff Input::,
629 for the complete contents of the two files).  Notice that at most one
630 context line is reported here.
631
632      *** lao    2002-02-21 23:30:39.942229878 -0800
633      --- tzu    2002-02-21 23:30:50.442260588 -0800
634      ***************
635      *** 1,5 ****
636      - The Way that can be told of is not the eternal Way;
637      - The name that can be named is not the eternal name.
638        The Nameless is the origin of Heaven and Earth;
639      ! The Named is the mother of all things.
640        Therefore let there always be non-being,
641      --- 1,4 ----
642        The Nameless is the origin of Heaven and Earth;
643      ! The named is the mother of all things.
644      !
645        Therefore let there always be non-being,
646      ***************
647      *** 11 ****
648      --- 10,13 ----
649          they have different names.
650      + They both may be called deep and profound.
651      + Deeper and more profound,
652      + The door of all subtleties!
653
654 \1f
655 File: diff.info,  Node: Detailed Context,  Prev: Less Context,  Up: Context Format
656
657 2.2.1.3 Detailed Description of Context Format
658 ..............................................
659
660 The context output format starts with a two-line header, which looks
661 like this:
662
663      *** FROM-FILE FROM-FILE-MODIFICATION-TIME
664      --- TO-FILE TO-FILE-MODIFICATION TIME
665
666 The time stamp normally looks like `2002-02-21 23:30:39.942229878
667 -0800' to indicate the date, time with fractional seconds, and time
668 zone in Internet RFC 2822 format
669 (ftp://ftp.isi.edu/in-notes/rfc2822.txt).  (The fractional seconds are
670 omitted on hosts that do not support fractional time stamps.)  However,
671 a traditional time stamp like `Thu Feb 21 23:30:39 2002' is used if the
672 `LC_TIME' locale category is either `C' or `POSIX'.
673
674    You can change the header's content with the `--label=LABEL' option;
675 see *note Alternate Names::.
676
677    Next come one or more hunks of differences; each hunk shows one area
678 where the files differ.  Context format hunks look like this:
679
680      ***************
681      *** FROM-FILE-LINE-NUMBERS ****
682        FROM-FILE-LINE
683        FROM-FILE-LINE...
684      --- TO-FILE-LINE-NUMBERS ----
685        TO-FILE-LINE
686        TO-FILE-LINE...
687
688    If a hunk contains two or more lines, its line numbers look like
689 `START,END'.  Otherwise only its end line number appears.  An empty
690 hunk is considered to end at the line that precedes the hunk.
691
692    The lines of context around the lines that differ start with two
693 space characters.  The lines that differ between the two files start
694 with one of the following indicator characters, followed by a space
695 character:
696
697 `!'
698      A line that is part of a group of one or more lines that changed
699      between the two files.  There is a corresponding group of lines
700      marked with `!' in the part of this hunk for the other file.
701
702 `+'
703      An "inserted" line in the second file that corresponds to nothing
704      in the first file.
705
706 `-'
707      A "deleted" line in the first file that corresponds to nothing in
708      the second file.
709
710    If all of the changes in a hunk are insertions, the lines of
711 FROM-FILE are omitted.  If all of the changes are deletions, the lines
712 of TO-FILE are omitted.
713
714 \1f
715 File: diff.info,  Node: Unified Format,  Next: Sections,  Prev: Context Format,  Up: Context
716
717 2.2.2 Unified Format
718 --------------------
719
720 The unified output format is a variation on the context format that is
721 more compact because it omits redundant context lines.  To select this
722 output format, use the `-U LINES', `--unified[=LINES]', or `-u' option.
723 The argument LINES is the number of lines of context to show.  When it
724 is not given, it defaults to three.
725
726    At present, only GNU `diff' can produce this format and only GNU
727 `patch' can automatically apply diffs in this format.  For proper
728 operation, `patch' typically needs at least three lines of context.
729
730 * Menu:
731
732 * Example Unified::  Sample output in unified format.
733 * Detailed Unified:: A detailed description of unified format.
734
735 \1f
736 File: diff.info,  Node: Example Unified,  Next: Detailed Unified,  Up: Unified Format
737
738 2.2.2.1 An Example of Unified Format
739 ....................................
740
741 Here is the output of the command `diff -u lao tzu' (*note Sample diff
742 Input::, for the complete contents of the two files):
743
744      --- lao    2002-02-21 23:30:39.942229878 -0800
745      +++ tzu    2002-02-21 23:30:50.442260588 -0800
746      @@ -1,7 +1,6 @@
747      -The Way that can be told of is not the eternal Way;
748      -The name that can be named is not the eternal name.
749       The Nameless is the origin of Heaven and Earth;
750      -The Named is the mother of all things.
751      +The named is the mother of all things.
752      +
753       Therefore let there always be non-being,
754         so we may see their subtlety,
755       And let there always be being,
756      @@ -9,3 +8,6 @@
757       The two are the same,
758       But after they are produced,
759         they have different names.
760      +They both may be called deep and profound.
761      +Deeper and more profound,
762      +The door of all subtleties!
763
764 \1f
765 File: diff.info,  Node: Detailed Unified,  Prev: Example Unified,  Up: Unified Format
766
767 2.2.2.2 Detailed Description of Unified Format
768 ..............................................
769
770 The unified output format starts with a two-line header, which looks
771 like this:
772
773      --- FROM-FILE FROM-FILE-MODIFICATION-TIME
774      +++ TO-FILE TO-FILE-MODIFICATION-TIME
775
776 The time stamp looks like `2002-02-21 23:30:39.942229878 -0800' to
777 indicate the date, time with fractional seconds, and time zone.  The
778 fractional seconds are omitted on hosts that do not support fractional
779 time stamps.
780
781    You can change the header's content with the `--label=LABEL' option;
782 see *Note Alternate Names::.
783
784    Next come one or more hunks of differences; each hunk shows one area
785 where the files differ.  Unified format hunks look like this:
786
787      @@ FROM-FILE-LINE-NUMBERS TO-FILE-LINE-NUMBERS @@
788       LINE-FROM-EITHER-FILE
789       LINE-FROM-EITHER-FILE...
790
791    If a hunk contains just one line, only its start line number appears.
792 Otherwise its line numbers look like `START,COUNT'.  An empty hunk is
793 considered to start at the line that follows the hunk.
794
795    If a hunk and its context contain two or more lines, its line
796 numbers look like `START,COUNT'.  Otherwise only its end line number
797 appears.  An empty hunk is considered to end at the line that precedes
798 the hunk.
799
800    The lines common to both files begin with a space character.  The
801 lines that actually differ between the two files have one of the
802 following indicator characters in the left print column:
803
804 `+'
805      A line was added here to the first file.
806
807 `-'
808      A line was removed here from the first file.
809
810 \1f
811 File: diff.info,  Node: Sections,  Next: Alternate Names,  Prev: Unified Format,  Up: Context
812
813 2.2.3 Showing Which Sections Differences Are in
814 -----------------------------------------------
815
816 Sometimes you might want to know which part of the files each change
817 falls in.  If the files are source code, this could mean which function
818 was changed.  If the files are documents, it could mean which chapter
819 or appendix was changed.  GNU `diff' can show this by displaying the
820 nearest section heading line that precedes the differing lines.  Which
821 lines are "section headings" is determined by a regular expression.
822
823 * Menu:
824
825 * Specified Headings::  Showing headings that match regular expressions.
826 * C Function Headings:: Showing headings of C functions.
827
828 \1f
829 File: diff.info,  Node: Specified Headings,  Next: C Function Headings,  Up: Sections
830
831 2.2.3.1 Showing Lines That Match Regular Expressions
832 ....................................................
833
834 To show in which sections differences occur for files that are not
835 source code for C or similar languages, use the `-F REGEXP' or
836 `--show-function-line=REGEXP' option.  `diff' considers lines that
837 match the `grep'-style regular expression REGEXP to be the beginning of
838 a section of the file.  Here are suggested regular expressions for some
839 common languages:
840
841 `^[[:alpha:]$_]'
842      C, C++, Prolog
843
844 `^('
845      Lisp
846
847 `^@node'
848      Texinfo
849
850    This option does not automatically select an output format; in order
851 to use it, you must select the context format (*note Context Format::)
852 or unified format (*note Unified Format::).  In other output formats it
853 has no effect.
854
855    The `-F' or `--show-function-line' option finds the nearest
856 unchanged line that precedes each hunk of differences and matches the
857 given regular expression.  Then it adds that line to the end of the
858 line of asterisks in the context format, or to the `@@' line in unified
859 format.  If no matching line exists, this option leaves the output for
860 that hunk unchanged.  If that line is more than 40 characters long, it
861 outputs only the first 40 characters.  You can specify more than one
862 regular expression for such lines; `diff' tries to match each line
863 against each regular expression, starting with the last one given.  This
864 means that you can use `-p' and `-F' together, if you wish.
865
866 \1f
867 File: diff.info,  Node: C Function Headings,  Prev: Specified Headings,  Up: Sections
868
869 2.2.3.2 Showing C Function Headings
870 ...................................
871
872 To show in which functions differences occur for C and similar
873 languages, you can use the `-p' or `--show-c-function' option.  This
874 option automatically defaults to the context output format (*note
875 Context Format::), with the default number of lines of context.  You
876 can override that number with `-C LINES' elsewhere in the command line.
877 You can override both the format and the number with `-U LINES'
878 elsewhere in the command line.
879
880    The `-p' or `--show-c-function' option is equivalent to `-F
881 '^[[:alpha:]$_]'' if the unified format is specified, otherwise `-c -F
882 '^[[:alpha:]$_]'' (*note Specified Headings::).  GNU `diff' provides
883 this option for the sake of convenience.
884
885 \1f
886 File: diff.info,  Node: Alternate Names,  Prev: Sections,  Up: Context
887
888 2.2.4 Showing Alternate File Names
889 ----------------------------------
890
891 If you are comparing two files that have meaningless or uninformative
892 names, you might want `diff' to show alternate names in the header of
893 the context and unified output formats.  To do this, use the
894 `--label=LABEL' option.  The first time you give this option, its
895 argument replaces the name and date of the first file in the header;
896 the second time, its argument replaces the name and date of the second
897 file.  If you give this option more than twice, `diff' reports an
898 error.  The `--label' option does not affect the file names in the `pr'
899 header when the `-l' or `--paginate' option is used (*note
900 Pagination::).
901
902    Here are the first two lines of the output from `diff -C 2
903 --label=original --label=modified lao tzu':
904
905      *** original
906      --- modified
907
908 \1f
909 File: diff.info,  Node: Side by Side,  Next: Normal,  Prev: Context,  Up: Output Formats
910
911 2.3 Showing Differences Side by Side
912 ====================================
913
914 `diff' can produce a side by side difference listing of two files.  The
915 files are listed in two columns with a gutter between them.  The gutter
916 contains one of the following markers:
917
918 white space
919      The corresponding lines are in common.  That is, either the lines
920      are identical, or the difference is ignored because of one of the
921      `--ignore' options (*note White Space::).
922
923 `|'
924      The corresponding lines differ, and they are either both complete
925      or both incomplete.
926
927 `<'
928      The files differ and only the first file contains the line.
929
930 `>'
931      The files differ and only the second file contains the line.
932
933 `('
934      Only the first file contains the line, but the difference is
935      ignored.
936
937 `)'
938      Only the second file contains the line, but the difference is
939      ignored.
940
941 `\'
942      The corresponding lines differ, and only the first line is
943      incomplete.
944
945 `/'
946      The corresponding lines differ, and only the second line is
947      incomplete.
948
949    Normally, an output line is incomplete if and only if the lines that
950 it contains are incomplete; *Note Incomplete Lines::.  However, when an
951 output line represents two differing lines, one might be incomplete
952 while the other is not.  In this case, the output line is complete, but
953 its the gutter is marked `\' if the first line is incomplete, `/' if
954 the second line is.
955
956    Side by side format is sometimes easiest to read, but it has
957 limitations.  It generates much wider output than usual, and truncates
958 lines that are too long to fit.  Also, it relies on lining up output
959 more heavily than usual, so its output looks particularly bad if you
960 use varying width fonts, nonstandard tab stops, or nonprinting
961 characters.
962
963    You can use the `sdiff' command to interactively merge side by side
964 differences.  *Note Interactive Merging::, for more information on
965 merging files.
966
967 * Menu:
968
969 * Side by Side Format::  Controlling side by side output format.
970 * Example Side by Side:: Sample side by side output.
971
972 \1f
973 File: diff.info,  Node: Side by Side Format,  Next: Example Side by Side,  Up: Side by Side
974
975 2.3.1 Controlling Side by Side Format
976 -------------------------------------
977
978 The `-y' or `--side-by-side' option selects side by side format.
979 Because side by side output lines contain two input lines, the output
980 is wider than usual: normally 130 print columns, which can fit onto a
981 traditional printer line.  You can set the width of the output with the
982 `-W COLUMNS' or `--width=COLUMNS' option.  The output is split into two
983 halves of equal width, separated by a small gutter to mark differences;
984 the right half is aligned to a tab stop so that tabs line up.  Input
985 lines that are too long to fit in half of an output line are truncated
986 for output.
987
988    The `--left-column' option prints only the left column of two common
989 lines.  The `--suppress-common-lines' option suppresses common lines
990 entirely.
991
992 \1f
993 File: diff.info,  Node: Example Side by Side,  Prev: Side by Side Format,  Up: Side by Side
994
995 2.3.2 An Example of Side by Side Format
996 ---------------------------------------
997
998 Here is the output of the command `diff -y -W 72 lao tzu' (*note Sample
999 diff Input::, for the complete contents of the two files).
1000
1001      The Way that can be told of is n   <
1002      The name that can be named is no   <
1003      The Nameless is the origin of He        The Nameless is the origin of He
1004      The Named is the mother of all t   |    The named is the mother of all t
1005                                         >
1006      Therefore let there always be no        Therefore let there always be no
1007        so we may see their subtlety,           so we may see their subtlety,
1008      And let there always be being,          And let there always be being,
1009        so we may see their outcome.            so we may see their outcome.
1010      The two are the same,                   The two are the same,
1011      But after they are produced,            But after they are produced,
1012        they have different names.              they have different names.
1013                                         >    They both may be called deep and
1014                                         >    Deeper and more profound,
1015                                         >    The door of all subtleties!
1016
1017 \1f
1018 File: diff.info,  Node: Normal,  Next: Scripts,  Prev: Side by Side,  Up: Output Formats
1019
1020 2.4 Showing Differences Without Context
1021 =======================================
1022
1023 The "normal" `diff' output format shows each hunk of differences
1024 without any surrounding context.  Sometimes such output is the clearest
1025 way to see how lines have changed, without the clutter of nearby
1026 unchanged lines (although you can get similar results with the context
1027 or unified formats by using 0 lines of context).  However, this format
1028 is no longer widely used for sending out patches; for that purpose, the
1029 context format (*note Context Format::) and the unified format (*note
1030 Unified Format::) are superior.  Normal format is the default for
1031 compatibility with older versions of `diff' and the POSIX standard.
1032 Use the `--normal' option to select this output format explicitly.
1033
1034 * Menu:
1035
1036 * Example Normal::  Sample output in the normal format.
1037 * Detailed Normal:: A detailed description of normal output format.
1038
1039 \1f
1040 File: diff.info,  Node: Example Normal,  Next: Detailed Normal,  Up: Normal
1041
1042 2.4.1 An Example of Normal Format
1043 ---------------------------------
1044
1045 Here is the output of the command `diff lao tzu' (*note Sample diff
1046 Input::, for the complete contents of the two files).  Notice that it
1047 shows only the lines that are different between the two files.
1048
1049      1,2d0
1050      < The Way that can be told of is not the eternal Way;
1051      < The name that can be named is not the eternal name.
1052      4c2,3
1053      < The Named is the mother of all things.
1054      ---
1055      > The named is the mother of all things.
1056      >
1057      11a11,13
1058      > They both may be called deep and profound.
1059      > Deeper and more profound,
1060      > The door of all subtleties!
1061
1062 \1f
1063 File: diff.info,  Node: Detailed Normal,  Prev: Example Normal,  Up: Normal
1064
1065 2.4.2 Detailed Description of Normal Format
1066 -------------------------------------------
1067
1068 The normal output format consists of one or more hunks of differences;
1069 each hunk shows one area where the files differ.  Normal format hunks
1070 look like this:
1071
1072      CHANGE-COMMAND
1073      < FROM-FILE-LINE
1074      < FROM-FILE-LINE...
1075      ---
1076      > TO-FILE-LINE
1077      > TO-FILE-LINE...
1078
1079    There are three types of change commands.  Each consists of a line
1080 number or comma-separated range of lines in the first file, a single
1081 character indicating the kind of change to make, and a line number or
1082 comma-separated range of lines in the second file.  All line numbers are
1083 the original line numbers in each file.  The types of change commands
1084 are:
1085
1086 `LaR'
1087      Add the lines in range R of the second file after line L of the
1088      first file.  For example, `8a12,15' means append lines 12-15 of
1089      file 2 after line 8 of file 1; or, if changing file 2 into file 1,
1090      delete lines 12-15 of file 2.
1091
1092 `FcT'
1093      Replace the lines in range F of the first file with lines in range
1094      T of the second file.  This is like a combined add and delete, but
1095      more compact.  For example, `5,7c8,10' means change lines 5-7 of
1096      file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
1097      file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.
1098
1099 `RdL'
1100      Delete the lines in range R from the first file; line L is where
1101      they would have appeared in the second file had they not been
1102      deleted.  For example, `5,7d3' means delete lines 5-7 of file 1;
1103      or, if changing file 2 into file 1, append lines 5-7 of file 1
1104      after line 3 of file 2.
1105
1106 \1f
1107 File: diff.info,  Node: Scripts,  Next: If-then-else,  Prev: Normal,  Up: Output Formats
1108
1109 2.5 Making Edit Scripts
1110 =======================
1111
1112 Several output modes produce command scripts for editing FROM-FILE to
1113 produce TO-FILE.
1114
1115 * Menu:
1116
1117 * ed Scripts:: Using `diff' to produce commands for `ed'.
1118 * Forward ed:: Making forward `ed' scripts.
1119 * RCS::        A special `diff' output format used by RCS.
1120
1121 \1f
1122 File: diff.info,  Node: ed Scripts,  Next: Forward ed,  Up: Scripts
1123
1124 2.5.1 `ed' Scripts
1125 ------------------
1126
1127 `diff' can produce commands that direct the `ed' text editor to change
1128 the first file into the second file.  Long ago, this was the only
1129 output mode that was suitable for editing one file into another
1130 automatically; today, with `patch', it is almost obsolete.  Use the
1131 `-e' or `--ed' option to select this output format.
1132
1133    Like the normal format (*note Normal::), this output format does not
1134 show any context; unlike the normal format, it does not include the
1135 information necessary to apply the diff in reverse (to produce the first
1136 file if all you have is the second file and the diff).
1137
1138    If the file `d' contains the output of `diff -e old new', then the
1139 command `(cat d && echo w) | ed - old' edits `old' to make it a copy of
1140 `new'.  More generally, if `d1', `d2', ..., `dN' contain the outputs of
1141 `diff -e old new1', `diff -e new1 new2', ..., `diff -e newN-1 newN',
1142 respectively, then the command `(cat d1 d2 ... dN && echo w) | ed -
1143 old' edits `old' to make it a copy of `newN'.
1144
1145 * Menu:
1146
1147 * Example ed::  A sample `ed' script.
1148 * Detailed ed:: A detailed description of `ed' format.
1149
1150 \1f
1151 File: diff.info,  Node: Example ed,  Next: Detailed ed,  Up: ed Scripts
1152
1153 2.5.1.1 Example `ed' Script
1154 ...........................
1155
1156 Here is the output of `diff -e lao tzu' (*note Sample diff Input::, for
1157 the complete contents of the two files):
1158
1159      11a
1160      They both may be called deep and profound.
1161      Deeper and more profound,
1162      The door of all subtleties!
1163      .
1164      4c
1165      The named is the mother of all things.
1166
1167      .
1168      1,2d
1169
1170 \1f
1171 File: diff.info,  Node: Detailed ed,  Prev: Example ed,  Up: ed Scripts
1172
1173 2.5.1.2 Detailed Description of `ed' Format
1174 ...........................................
1175
1176 The `ed' output format consists of one or more hunks of differences.
1177 The changes closest to the ends of the files come first so that
1178 commands that change the number of lines do not affect how `ed'
1179 interprets line numbers in succeeding commands.  `ed' format hunks look
1180 like this:
1181
1182      CHANGE-COMMAND
1183      TO-FILE-LINE
1184      TO-FILE-LINE...
1185      .
1186
1187    Because `ed' uses a single period on a line to indicate the end of
1188 input, GNU `diff' protects lines of changes that contain a single
1189 period on a line by writing two periods instead, then writing a
1190 subsequent `ed' command to change the two periods into one.  The `ed'
1191 format cannot represent an incomplete line, so if the second file ends
1192 in a changed incomplete line, `diff' reports an error and then pretends
1193 that a newline was appended.
1194
1195    There are three types of change commands.  Each consists of a line
1196 number or comma-separated range of lines in the first file and a single
1197 character indicating the kind of change to make.  All line numbers are
1198 the original line numbers in the file.  The types of change commands
1199 are:
1200
1201 `La'
1202      Add text from the second file after line L in the first file.  For
1203      example, `8a' means to add the following lines after line 8 of file
1204      1.
1205
1206 `Rc'
1207      Replace the lines in range R in the first file with the following
1208      lines.  Like a combined add and delete, but more compact.  For
1209      example, `5,7c' means change lines 5-7 of file 1 to read as the
1210      text file 2.
1211
1212 `Rd'
1213      Delete the lines in range R from the first file.  For example,
1214      `5,7d' means delete lines 5-7 of file 1.
1215
1216 \1f
1217 File: diff.info,  Node: Forward ed,  Next: RCS,  Prev: ed Scripts,  Up: Scripts
1218
1219 2.5.2 Forward `ed' Scripts
1220 --------------------------
1221
1222 `diff' can produce output that is like an `ed' script, but with hunks
1223 in forward (front to back) order.  The format of the commands is also
1224 changed slightly: command characters precede the lines they modify,
1225 spaces separate line numbers in ranges, and no attempt is made to
1226 disambiguate hunk lines consisting of a single period.  Like `ed'
1227 format, forward `ed' format cannot represent incomplete lines.
1228
1229    Forward `ed' format is not very useful, because neither `ed' nor
1230 `patch' can apply diffs in this format.  It exists mainly for
1231 compatibility with older versions of `diff'.  Use the `-f' or
1232 `--forward-ed' option to select it.
1233
1234 \1f
1235 File: diff.info,  Node: RCS,  Prev: Forward ed,  Up: Scripts
1236
1237 2.5.3 RCS Scripts
1238 -----------------
1239
1240 The RCS output format is designed specifically for use by the Revision
1241 Control System, which is a set of free programs used for organizing
1242 different versions and systems of files.  Use the `-n' or `--rcs'
1243 option to select this output format.  It is like the forward `ed'
1244 format (*note Forward ed::), but it can represent arbitrary changes to
1245 the contents of a file because it avoids the forward `ed' format's
1246 problems with lines consisting of a single period and with incomplete
1247 lines.  Instead of ending text sections with a line consisting of a
1248 single period, each command specifies the number of lines it affects; a
1249 combination of the `a' and `d' commands are used instead of `c'.  Also,
1250 if the second file ends in a changed incomplete line, then the output
1251 also ends in an incomplete line.
1252
1253    Here is the output of `diff -n lao tzu' (*note Sample diff Input::,
1254 for the complete contents of the two files):
1255
1256      d1 2
1257      d4 1
1258      a4 2
1259      The named is the mother of all things.
1260
1261      a11 3
1262      They both may be called deep and profound.
1263      Deeper and more profound,
1264      The door of all subtleties!
1265
1266 \1f
1267 File: diff.info,  Node: If-then-else,  Prev: Scripts,  Up: Output Formats
1268
1269 2.6 Merging Files with If-then-else
1270 ===================================
1271
1272 You can use `diff' to merge two files of C source code.  The output of
1273 `diff' in this format contains all the lines of both files.  Lines
1274 common to both files are output just once; the differing parts are
1275 separated by the C preprocessor directives `#ifdef NAME' or `#ifndef
1276 NAME', `#else', and `#endif'.  When compiling the output, you select
1277 which version to use by either defining or leaving undefined the macro
1278 NAME.
1279
1280    To merge two files, use `diff' with the `-D NAME' or `--ifdef=NAME'
1281 option.  The argument NAME is the C preprocessor identifier to use in
1282 the `#ifdef' and `#ifndef' directives.
1283
1284    For example, if you change an instance of `wait (&s)' to `waitpid
1285 (-1, &s, 0)' and then merge the old and new files with the
1286 `--ifdef=HAVE_WAITPID' option, then the affected part of your code
1287 might look like this:
1288
1289          do {
1290      #ifndef HAVE_WAITPID
1291              if ((w = wait (&s)) < 0  &&  errno != EINTR)
1292      #else /* HAVE_WAITPID */
1293              if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
1294      #endif /* HAVE_WAITPID */
1295                  return w;
1296          } while (w != child);
1297
1298    You can specify formats for languages other than C by using line
1299 group formats and line formats, as described in the next sections.
1300
1301 * Menu:
1302
1303 * Line Group Formats::    Formats for general if-then-else line groups.
1304 * Line Formats::          Formats for each line in a line group.
1305 * Example If-then-else::  Sample if-then-else format output.
1306 * Detailed If-then-else:: A detailed description of if-then-else format.
1307
1308 \1f
1309 File: diff.info,  Node: Line Group Formats,  Next: Line Formats,  Up: If-then-else
1310
1311 2.6.1 Line Group Formats
1312 ------------------------
1313
1314 Line group formats let you specify formats suitable for many
1315 applications that allow if-then-else input, including programming
1316 languages and text formatting languages.  A line group format specifies
1317 the output format for a contiguous group of similar lines.
1318
1319    For example, the following command compares the TeX files `old' and
1320 `new', and outputs a merged file in which old regions are surrounded by
1321 `\begin{em}'-`\end{em}' lines, and new regions are surrounded by
1322 `\begin{bf}'-`\end{bf}' lines.
1323
1324      diff \
1325         --old-group-format='\begin{em}
1326      %<\end{em}
1327      ' \
1328         --new-group-format='\begin{bf}
1329      %>\end{bf}
1330      ' \
1331         old new
1332
1333    The following command is equivalent to the above example, but it is a
1334 little more verbose, because it spells out the default line group
1335 formats.
1336
1337      diff \
1338         --old-group-format='\begin{em}
1339      %<\end{em}
1340      ' \
1341         --new-group-format='\begin{bf}
1342      %>\end{bf}
1343      ' \
1344         --unchanged-group-format='%=' \
1345         --changed-group-format='\begin{em}
1346      %<\end{em}
1347      \begin{bf}
1348      %>\end{bf}
1349      ' \
1350         old new
1351
1352    Here is a more advanced example, which outputs a diff listing with
1353 headers containing line numbers in a "plain English" style.
1354
1355      diff \
1356         --unchanged-group-format='' \
1357         --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
1358      %<' \
1359         --new-group-format='-------- %dN line%(N=1?:s) added after %de:
1360      %>' \
1361         --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
1362      %<-------- to:
1363      %>' \
1364         old new
1365
1366    To specify a line group format, use `diff' with one of the options
1367 listed below.  You can specify up to four line group formats, one for
1368 each kind of line group.  You should quote FORMAT, because it typically
1369 contains shell metacharacters.
1370
1371 `--old-group-format=FORMAT'
1372      These line groups are hunks containing only lines from the first
1373      file.  The default old group format is the same as the changed
1374      group format if it is specified; otherwise it is a format that
1375      outputs the line group as-is.
1376
1377 `--new-group-format=FORMAT'
1378      These line groups are hunks containing only lines from the second
1379      file.  The default new group format is same as the changed group
1380      format if it is specified; otherwise it is a format that outputs
1381      the line group as-is.
1382
1383 `--changed-group-format=FORMAT'
1384      These line groups are hunks containing lines from both files.  The
1385      default changed group format is the concatenation of the old and
1386      new group formats.
1387
1388 `--unchanged-group-format=FORMAT'
1389      These line groups contain lines common to both files.  The default
1390      unchanged group format is a format that outputs the line group
1391      as-is.
1392
1393    In a line group format, ordinary characters represent themselves;
1394 conversion specifications start with `%' and have one of the following
1395 forms.
1396
1397 `%<'
1398      stands for the lines from the first file, including the trailing
1399      newline.  Each line is formatted according to the old line format
1400      (*note Line Formats::).
1401
1402 `%>'
1403      stands for the lines from the second file, including the trailing
1404      newline.  Each line is formatted according to the new line format.
1405
1406 `%='
1407      stands for the lines common to both files, including the trailing
1408      newline.  Each line is formatted according to the unchanged line
1409      format.
1410
1411 `%%'
1412      stands for `%'.
1413
1414 `%c'C''
1415      where C is a single character, stands for C.  C may not be a
1416      backslash or an apostrophe.  For example, `%c':'' stands for a
1417      colon, even inside the then-part of an if-then-else format, which
1418      a colon would normally terminate.
1419
1420 `%c'\O''
1421      where O is a string of 1, 2, or 3 octal digits, stands for the
1422      character with octal code O.  For example, `%c'\0'' stands for a
1423      null character.
1424
1425 `FN'
1426      where F is a `printf' conversion specification and N is one of the
1427      following letters, stands for N's value formatted with F.
1428
1429     `e'
1430           The line number of the line just before the group in the old
1431           file.
1432
1433     `f'
1434           The line number of the first line in the group in the old
1435           file; equals E + 1.
1436
1437     `l'
1438           The line number of the last line in the group in the old file.
1439
1440     `m'
1441           The line number of the line just after the group in the old
1442           file; equals L + 1.
1443
1444     `n'
1445           The number of lines in the group in the old file; equals L -
1446           F + 1.
1447
1448     `E, F, L, M, N'
1449           Likewise, for lines in the new file.
1450
1451
1452      The `printf' conversion specification can be `%d', `%o', `%x', or
1453      `%X', specifying decimal, octal, lower case hexadecimal, or upper
1454      case hexadecimal output respectively.  After the `%' the following
1455      options can appear in sequence: a series of zero or more flags; an
1456      integer specifying the minimum field width; and a period followed
1457      by an optional integer specifying the minimum number of digits.
1458      The flags are `-' for left-justification, `'' for separating the
1459      digit into groups as specified by the `LC_NUMERIC' locale category,
1460      and `0' for padding with zeros instead of spaces.  For example,
1461      `%5dN' prints the number of new lines in the group in a field of
1462      width 5 characters, using the `printf' format `"%5d"'.
1463
1464 `(A=B?T:E)'
1465      If A equals B then T else E.  A and B are each either a decimal
1466      constant or a single letter interpreted as above.  This format
1467      spec is equivalent to T if A's value equals B's; otherwise it is
1468      equivalent to E.
1469
1470      For example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no
1471      lines' if N (the number of lines in the group in the new file) is
1472      0, to `1 line' if N is 1, and to `%dN lines' otherwise.
1473
1474 \1f
1475 File: diff.info,  Node: Line Formats,  Next: Example If-then-else,  Prev: Line Group Formats,  Up: If-then-else
1476
1477 2.6.2 Line Formats
1478 ------------------
1479
1480 Line formats control how each line taken from an input file is output
1481 as part of a line group in if-then-else format.
1482
1483    For example, the following command outputs text with a one-character
1484 change indicator to the left of the text.  The first character of output
1485 is `-' for deleted lines, `|' for added lines, and a space for
1486 unchanged lines.  The formats contain newline characters where newlines
1487 are desired on output.
1488
1489      diff \
1490         --old-line-format='-%l
1491      ' \
1492         --new-line-format='|%l
1493      ' \
1494         --unchanged-line-format=' %l
1495      ' \
1496         old new
1497
1498    To specify a line format, use one of the following options.  You
1499 should quote FORMAT, since it often contains shell metacharacters.
1500
1501 `--old-line-format=FORMAT'
1502      formats lines just from the first file.
1503
1504 `--new-line-format=FORMAT'
1505      formats lines just from the second file.
1506
1507 `--unchanged-line-format=FORMAT'
1508      formats lines common to both files.
1509
1510 `--line-format=FORMAT'
1511      formats all lines; in effect, it sets all three above options
1512      simultaneously.
1513
1514    In a line format, ordinary characters represent themselves;
1515 conversion specifications start with `%' and have one of the following
1516 forms.
1517
1518 `%l'
1519      stands for the contents of the line, not counting its trailing
1520      newline (if any).  This format ignores whether the line is
1521      incomplete; *Note Incomplete Lines::.
1522
1523 `%L'
1524      stands for the contents of the line, including its trailing newline
1525      (if any).  If a line is incomplete, this format preserves its
1526      incompleteness.
1527
1528 `%%'
1529      stands for `%'.
1530
1531 `%c'C''
1532      where C is a single character, stands for C.  C may not be a
1533      backslash or an apostrophe.  For example, `%c':'' stands for a
1534      colon.
1535
1536 `%c'\O''
1537      where O is a string of 1, 2, or 3 octal digits, stands for the
1538      character with octal code O.  For example, `%c'\0'' stands for a
1539      null character.
1540
1541 `Fn'
1542      where F is a `printf' conversion specification, stands for the
1543      line number formatted with F.  For example, `%.5dn' prints the
1544      line number using the `printf' format `"%.5d"'.  *Note Line Group
1545      Formats::, for more about printf conversion specifications.
1546
1547
1548    The default line format is `%l' followed by a newline character.
1549
1550    If the input contains tab characters and it is important that they
1551 line up on output, you should ensure that `%l' or `%L' in a line format
1552 is just after a tab stop (e.g. by preceding `%l' or `%L' with a tab
1553 character), or you should use the `-t' or `--expand-tabs' option.
1554
1555    Taken together, the line and line group formats let you specify many
1556 different formats.  For example, the following command uses a format
1557 similar to normal `diff' format.  You can tailor this command to get
1558 fine control over `diff' output.
1559
1560      diff \
1561         --old-line-format='< %l
1562      ' \
1563         --new-line-format='> %l
1564      ' \
1565         --old-group-format='%df%(f=l?:,%dl)d%dE
1566      %<' \
1567         --new-group-format='%dea%dF%(F=L?:,%dL)
1568      %>' \
1569         --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
1570      %<---
1571      %>' \
1572         --unchanged-group-format='' \
1573         old new
1574
1575 \1f
1576 File: diff.info,  Node: Example If-then-else,  Next: Detailed If-then-else,  Prev: Line Formats,  Up: If-then-else
1577
1578 2.6.3 An Example of If-then-else Format
1579 ---------------------------------------
1580
1581 Here is the output of `diff -DTWO lao tzu' (*note Sample diff Input::,
1582 for the complete contents of the two files):
1583
1584      #ifndef TWO
1585      The Way that can be told of is not the eternal Way;
1586      The name that can be named is not the eternal name.
1587      #endif /* ! TWO */
1588      The Nameless is the origin of Heaven and Earth;
1589      #ifndef TWO
1590      The Named is the mother of all things.
1591      #else /* TWO */
1592      The named is the mother of all things.
1593
1594      #endif /* TWO */
1595      Therefore let there always be non-being,
1596        so we may see their subtlety,
1597      And let there always be being,
1598        so we may see their outcome.
1599      The two are the same,
1600      But after they are produced,
1601        they have different names.
1602      #ifdef TWO
1603      They both may be called deep and profound.
1604      Deeper and more profound,
1605      The door of all subtleties!
1606      #endif /* TWO */
1607
1608 \1f
1609 File: diff.info,  Node: Detailed If-then-else,  Prev: Example If-then-else,  Up: If-then-else
1610
1611 2.6.4 Detailed Description of If-then-else Format
1612 -------------------------------------------------
1613
1614 For lines common to both files, `diff' uses the unchanged line group
1615 format.  For each hunk of differences in the merged output format, if
1616 the hunk contains only lines from the first file, `diff' uses the old
1617 line group format; if the hunk contains only lines from the second
1618 file, `diff' uses the new group format; otherwise, `diff' uses the
1619 changed group format.
1620
1621    The old, new, and unchanged line formats specify the output format of
1622 lines from the first file, lines from the second file, and lines common
1623 to both files, respectively.
1624
1625    The option `--ifdef=NAME' is equivalent to the following sequence of
1626 options using shell syntax:
1627
1628      --old-group-format='#ifndef NAME
1629      %<#endif /* ! NAME */
1630      ' \
1631      --new-group-format='#ifdef NAME
1632      %>#endif /* NAME */
1633      ' \
1634      --unchanged-group-format='%=' \
1635      --changed-group-format='#ifndef NAME
1636      %<#else /* NAME */
1637      %>#endif /* NAME */
1638      '
1639
1640    You should carefully check the `diff' output for proper nesting.
1641 For example, when using the `-D NAME' or `--ifdef=NAME' option, you
1642 should check that if the differing lines contain any of the C
1643 preprocessor directives `#ifdef', `#ifndef', `#else', `#elif', or
1644 `#endif', they are nested properly and match.  If they don't, you must
1645 make corrections manually.  It is a good idea to carefully check the
1646 resulting code anyway to make sure that it really does what you want it
1647 to; depending on how the input files were produced, the output might
1648 contain duplicate or otherwise incorrect code.
1649
1650    The `patch' `-D NAME' option behaves like the `diff' `-D NAME'
1651 option, except it operates on a file and a diff to produce a merged
1652 file; *Note patch Options::.
1653
1654 \1f
1655 File: diff.info,  Node: Incomplete Lines,  Next: Comparing Directories,  Prev: Output Formats,  Up: Top
1656
1657 3 Incomplete Lines
1658 ******************
1659
1660 When an input file ends in a non-newline character, its last line is
1661 called an "incomplete line" because its last character is not a
1662 newline.  All other lines are called "full lines" and end in a newline
1663 character.  Incomplete lines do not match full lines unless differences
1664 in white space are ignored (*note White Space::).
1665
1666    An incomplete line is normally distinguished on output from a full
1667 line by a following line that starts with `\'.  However, the RCS format
1668 (*note RCS::) outputs the incomplete line as-is, without any trailing
1669 newline or following line.  The side by side format normally represents
1670 incomplete lines as-is, but in some cases uses a `\' or `/' gutter
1671 marker; *Note Side by Side::.  The if-then-else line format preserves a
1672 line's incompleteness with `%L', and discards the newline with `%l';
1673 *Note Line Formats::.  Finally, with the `ed' and forward `ed' output
1674 formats (*note Output Formats::) `diff' cannot represent an incomplete
1675 line, so it pretends there was a newline and reports an error.
1676
1677    For example, suppose `F' and `G' are one-byte files that contain
1678 just `f' and `g', respectively.  Then `diff F G' outputs
1679
1680      1c1
1681      < f
1682      \ No newline at end of file
1683      ---
1684      > g
1685      \ No newline at end of file
1686
1687 (The exact message may differ in non-English locales.)  `diff -n F G'
1688 outputs the following without a trailing newline:
1689
1690      d1 1
1691      a1 1
1692      g
1693
1694 `diff -e F G' reports two errors and outputs the following:
1695
1696      1c
1697      g
1698      .
1699
1700 \1f
1701 File: diff.info,  Node: Comparing Directories,  Next: Adjusting Output,  Prev: Incomplete Lines,  Up: Top
1702
1703 4 Comparing Directories
1704 ***********************
1705
1706 You can use `diff' to compare some or all of the files in two directory
1707 trees.  When both file name arguments to `diff' are directories, it
1708 compares each file that is contained in both directories, examining
1709 file names in alphabetical order as specified by the `LC_COLLATE'
1710 locale category.  Normally `diff' is silent about pairs of files that
1711 contain no differences, but if you use the `-s' or
1712 `--report-identical-files' option, it reports pairs of identical files.
1713 Normally `diff' reports subdirectories common to both directories
1714 without comparing subdirectories' files, but if you use the `-r' or
1715 `--recursive' option, it compares every corresponding pair of files in
1716 the directory trees, as many levels deep as they go.
1717
1718    For file names that are in only one of the directories, `diff'
1719 normally does not show the contents of the file that exists; it reports
1720 only that the file exists in that directory and not in the other.  You
1721 can make `diff' act as though the file existed but was empty in the
1722 other directory, so that it outputs the entire contents of the file that
1723 actually exists.  (It is output as either an insertion or a deletion,
1724 depending on whether it is in the first or the second directory given.)
1725 To do this, use the `-N' or `--new-file' option.
1726
1727    If the older directory contains one or more large files that are not
1728 in the newer directory, you can make the patch smaller by using the
1729 `--unidirectional-new-file' option instead of `-N'.  This option is
1730 like `-N' except that it only inserts the contents of files that appear
1731 in the second directory but not the first (that is, files that were
1732 added).  At the top of the patch, write instructions for the user
1733 applying the patch to remove the files that were deleted before
1734 applying the patch.  *Note Making Patches::, for more discussion of
1735 making patches for distribution.
1736
1737    To ignore some files while comparing directories, use the `-x
1738 PATTERN' or `--exclude=PATTERN' option.  This option ignores any files
1739 or subdirectories whose base names match the shell pattern PATTERN.
1740 Unlike in the shell, a period at the start of the base of a file name
1741 matches a wildcard at the start of a pattern.  You should enclose
1742 PATTERN in quotes so that the shell does not expand it.  For example,
1743 the option `-x '*.[ao]'' ignores any file whose name ends with `.a' or
1744 `.o'.
1745
1746    This option accumulates if you specify it more than once.  For
1747 example, using the options `-x 'RCS' -x '*,v'' ignores any file or
1748 subdirectory whose base name is `RCS' or ends with `,v'.
1749
1750    If you need to give this option many times, you can instead put the
1751 patterns in a file, one pattern per line, and use the `-X FILE' or
1752 `--exclude-from=FILE' option.  Trailing white space and empty lines are
1753 ignored in the pattern file.
1754
1755    If you have been comparing two directories and stopped partway
1756 through, later you might want to continue where you left off.  You can
1757 do this by using the `-S FILE' or `--starting-file=FILE' option.  This
1758 compares only the file FILE and all alphabetically later files in the
1759 topmost directory level.
1760
1761    If two directories differ only in that file names are lower case in
1762 one directory and upper case in the upper, `diff' normally reports many
1763 differences because it compares file names in a case sensitive way.
1764 With the `--ignore-file-name-case' option, `diff' ignores case
1765 differences in file names, so that for example the contents of the file
1766 `Tao' in one directory are compared to the contents of the file `TAO'
1767 in the other.  The `--no-ignore-file-name-case' option cancels the
1768 effect of the `--ignore-file-name-case' option, reverting to the default
1769 behavior.
1770
1771    If an `-x PATTERN' or `--exclude=PATTERN' option, or an `-X FILE' or
1772 `--exclude-from=FILE' option, is specified while the
1773 `--ignore-file-name-case' option is in effect, case is ignored when
1774 excluding file names matching the specified patterns.
1775
1776 \1f
1777 File: diff.info,  Node: Adjusting Output,  Next: diff Performance,  Prev: Comparing Directories,  Up: Top
1778
1779 5 Making `diff' Output Prettier
1780 *******************************
1781
1782 `diff' provides several ways to adjust the appearance of its output.
1783 These adjustments can be applied to any output format.
1784
1785 * Menu:
1786
1787 * Tabs::            Preserving the alignment of tab stops.
1788 * Trailing Blanks:: Suppressing blanks before empty output lines.
1789 * Pagination::      Page numbering and time-stamping `diff' output.
1790
1791 \1f
1792 File: diff.info,  Node: Tabs,  Next: Trailing Blanks,  Up: Adjusting Output
1793
1794 5.1 Preserving Tab Stop Alignment
1795 =================================
1796
1797 The lines of text in some of the `diff' output formats are preceded by
1798 one or two characters that indicate whether the text is inserted,
1799 deleted, or changed.  The addition of those characters can cause tabs
1800 to move to the next tab stop, throwing off the alignment of columns in
1801 the line.  GNU `diff' provides two ways to make tab-aligned columns
1802 line up correctly.
1803
1804    The first way is to have `diff' convert all tabs into the correct
1805 number of spaces before outputting them; select this method with the
1806 `-t' or `--expand-tabs' option.  To use this form of output with
1807 `patch', you must give `patch' the `-l' or `--ignore-white-space'
1808 option (*note Changed White Space::, for more information).  `diff'
1809 normally assumes that tab stops are set every 8 print columns, but this
1810 can be altered by the `--tabsize=COLUMNS' option.
1811
1812    The other method for making tabs line up correctly is to add a tab
1813 character instead of a space after the indicator character at the
1814 beginning of the line.  This ensures that all following tab characters
1815 are in the same position relative to tab stops that they were in the
1816 original files, so that the output is aligned correctly.  Its
1817 disadvantage is that it can make long lines too long to fit on one line
1818 of the screen or the paper.  It also does not work with the unified
1819 output format, which does not have a space character after the change
1820 type indicator character.  Select this method with the `-T' or
1821 `--initial-tab' option.
1822
1823 \1f
1824 File: diff.info,  Node: Trailing Blanks,  Next: Pagination,  Prev: Tabs,  Up: Adjusting Output
1825
1826 5.2 Omitting trailing blanks
1827 ============================
1828
1829 When outputting lines in normal or context format, or outputting an
1830 unchanged line in unified format, `diff' normally outputs a blank just
1831 before each line.  If the line is empty, the output of `diff' therefore
1832 contains trailing blanks even though the input does not contain them.
1833 For example, when outputting an unchanged empty line in context format,
1834 `diff' normally outputs a line with two leading spaces.
1835
1836    Some text editors and email agents routinely delete trailing blanks,
1837 so it can be a problem to deal with diff output files that contain
1838 them.  You can avoid this problem with the `--suppress-blank-empty'
1839 option.  It causes `diff' to omit trailing blanks at the end of output
1840 lines in normal, context, and unified format, unless the trailing
1841 blanks were already present in the input.  This changes the output
1842 format slightly, so that output lines are guaranteed to never end in a
1843 blank unless an input line ends in a blank.  This format is less likely
1844 to be munged by text editors or by transmission via email.  It is
1845 accepted by GNU `patch' as well.
1846
1847 \1f
1848 File: diff.info,  Node: Pagination,  Prev: Trailing Blanks,  Up: Adjusting Output
1849
1850 5.3 Paginating `diff' Output
1851 ============================
1852
1853 It can be convenient to have long output page-numbered and time-stamped.
1854 The `-l' or `--paginate' option does this by sending the `diff' output
1855 through the `pr' program.  Here is what the page header might look like
1856 for `diff -lc lao tzu':
1857
1858      2002-02-22 14:20                 diff -lc lao tzu                 Page 1
1859
1860 \1f
1861 File: diff.info,  Node: diff Performance,  Next: Comparing Three Files,  Prev: Adjusting Output,  Up: Top
1862
1863 6 `diff' Performance Tradeoffs
1864 ******************************
1865
1866 GNU `diff' runs quite efficiently; however, in some circumstances you
1867 can cause it to run faster or produce a more compact set of changes.
1868
1869    One way to improve `diff' performance is to use hard or symbolic
1870 links to files instead of copies.  This improves performance because
1871 `diff' normally does not need to read two hard or symbolic links to the
1872 same file, since their contents must be identical.  For example,
1873 suppose you copy a large directory hierarchy, make a few changes to the
1874 copy, and then often use `diff -r' to compare the original to the copy.
1875 If the original files are read-only, you can greatly improve
1876 performance by creating the copy using hard or symbolic links (e.g.,
1877 with GNU `cp -lR' or `cp -sR').  Before editing a file in the copy for
1878 the first time, you should break the link and replace it with a regular
1879 copy.
1880
1881    You can also affect the performance of GNU `diff' by giving it
1882 options that change the way it compares files.  Performance has more
1883 than one dimension.  These options improve one aspect of performance at
1884 the cost of another, or they improve performance in some cases while
1885 hurting it in others.
1886
1887    The way that GNU `diff' determines which lines have changed always
1888 comes up with a near-minimal set of differences.  Usually it is good
1889 enough for practical purposes.  If the `diff' output is large, you
1890 might want `diff' to use a modified algorithm that sometimes produces a
1891 smaller set of differences.  The `-d' or `--minimal' option does this;
1892 however, it can also cause `diff' to run more slowly than usual, so it
1893 is not the default behavior.
1894
1895    When the files you are comparing are large and have small groups of
1896 changes scattered throughout them, you can use the
1897 `--speed-large-files' option to make a different modification to the
1898 algorithm that `diff' uses.  If the input files have a constant small
1899 density of changes, this option speeds up the comparisons without
1900 changing the output.  If not, `diff' might produce a larger set of
1901 differences; however, the output will still be correct.
1902
1903    Normally `diff' discards the prefix and suffix that is common to
1904 both files before it attempts to find a minimal set of differences.
1905 This makes `diff' run faster, but occasionally it may produce
1906 non-minimal output.  The `--horizon-lines=LINES' option prevents `diff'
1907 from discarding the last LINES lines of the prefix and the first LINES
1908 lines of the suffix.  This gives `diff' further opportunities to find a
1909 minimal output.
1910
1911    Suppose a run of changed lines includes a sequence of lines at one
1912 end and there is an identical sequence of lines just outside the other
1913 end.  The `diff' command is free to choose which identical sequence is
1914 included in the hunk.  In this case, `diff' normally shifts the hunk's
1915 boundaries when this merges adjacent hunks, or shifts a hunk's lines
1916 towards the end of the file.  Merging hunks can make the output look
1917 nicer in some cases.
1918
1919 \1f
1920 File: diff.info,  Node: Comparing Three Files,  Next: diff3 Merging,  Prev: diff Performance,  Up: Top
1921
1922 7 Comparing Three Files
1923 ***********************
1924
1925 Use the program `diff3' to compare three files and show any differences
1926 among them.  (`diff3' can also merge files; see *note diff3 Merging::).
1927
1928    The "normal" `diff3' output format shows each hunk of differences
1929 without surrounding context.  Hunks are labeled depending on whether
1930 they are two-way or three-way, and lines are annotated by their
1931 location in the input files.
1932
1933    *Note Invoking diff3::, for more information on how to run `diff3'.
1934
1935 * Menu:
1936
1937 * Sample diff3 Input::    Sample `diff3' input for examples.
1938 * Example diff3 Normal::  Sample output in the normal format.
1939 * diff3 Hunks::           The format of normal output format.
1940 * Detailed diff3 Normal:: A detailed description of normal output format.
1941
1942 \1f
1943 File: diff.info,  Node: Sample diff3 Input,  Next: Example diff3 Normal,  Up: Comparing Three Files
1944
1945 7.1 A Third Sample Input File
1946 =============================
1947
1948 Here is a third sample file that will be used in examples to illustrate
1949 the output of `diff3' and how various options can change it.  The first
1950 two files are the same that we used for `diff' (*note Sample diff
1951 Input::).  This is the third sample file, called `tao':
1952
1953      The Way that can be told of is not the eternal Way;
1954      The name that can be named is not the eternal name.
1955      The Nameless is the origin of Heaven and Earth;
1956      The named is the mother of all things.
1957
1958      Therefore let there always be non-being,
1959        so we may see their subtlety,
1960      And let there always be being,
1961        so we may see their result.
1962      The two are the same,
1963      But after they are produced,
1964        they have different names.
1965
1966        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1967
1968 \1f
1969 File: diff.info,  Node: Example diff3 Normal,  Next: diff3 Hunks,  Prev: Sample diff3 Input,  Up: Comparing Three Files
1970
1971 7.2 An Example of `diff3' Normal Format
1972 =======================================
1973
1974 Here is the output of the command `diff3 lao tzu tao' (*note Sample
1975 diff3 Input::, for the complete contents of the files).  Notice that it
1976 shows only the lines that are different among the three files.
1977
1978      ====2
1979      1:1,2c
1980      3:1,2c
1981        The Way that can be told of is not the eternal Way;
1982        The name that can be named is not the eternal name.
1983      2:0a
1984      ====1
1985      1:4c
1986        The Named is the mother of all things.
1987      2:2,3c
1988      3:4,5c
1989        The named is the mother of all things.
1990
1991      ====3
1992      1:8c
1993      2:7c
1994          so we may see their outcome.
1995      3:9c
1996          so we may see their result.
1997      ====
1998      1:11a
1999      2:11,13c
2000        They both may be called deep and profound.
2001        Deeper and more profound,
2002        The door of all subtleties!
2003      3:13,14c
2004
2005          -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2006
2007 \1f
2008 File: diff.info,  Node: Detailed diff3 Normal,  Prev: diff3 Hunks,  Up: Comparing Three Files
2009
2010 7.3 Detailed Description of `diff3' Normal Format
2011 =================================================
2012
2013 Each hunk begins with a line marked `===='.  Three-way hunks have plain
2014 `====' lines, and two-way hunks have `1', `2', or `3' appended to
2015 specify which of the three input files differ in that hunk.  The hunks
2016 contain copies of two or three sets of input lines each preceded by one
2017 or two commands identifying where the lines came from.
2018
2019    Normally, two spaces precede each copy of an input line to
2020 distinguish it from the commands.  But with the `-T' or `--initial-tab'
2021 option, `diff3' uses a tab instead of two spaces; this lines up tabs
2022 correctly.  *Note Tabs::, for more information.
2023
2024    Commands take the following forms:
2025
2026 `FILE:La'
2027      This hunk appears after line L of file FILE, and contains no lines
2028      in that file.  To edit this file to yield the other files, one
2029      must append hunk lines taken from the other files.  For example,
2030      `1:11a' means that the hunk follows line 11 in the first file and
2031      contains no lines from that file.
2032
2033 `FILE:Rc'
2034      This hunk contains the lines in the range R of file FILE.  The
2035      range R is a comma-separated pair of line numbers, or just one
2036      number if there is only one line.  To edit this file to yield the
2037      other files, one must change the specified lines to be the lines
2038      taken from the other files.  For example, `2:11,13c' means that
2039      the hunk contains lines 11 through 13 from the second file.
2040
2041    If the last line in a set of input lines is incomplete (*note
2042 Incomplete Lines::), it is distinguished on output from a full line by
2043 a following line that starts with `\'.
2044
2045 \1f
2046 File: diff.info,  Node: diff3 Hunks,  Next: Detailed diff3 Normal,  Prev: Example diff3 Normal,  Up: Comparing Three Files
2047
2048 7.4 `diff3' Hunks
2049 =================
2050
2051 Groups of lines that differ in two or three of the input files are
2052 called "diff3 hunks", by analogy with `diff' hunks (*note Hunks::).  If
2053 all three input files differ in a `diff3' hunk, the hunk is called a
2054 "three-way hunk"; if just two input files differ, it is a "two-way
2055 hunk".
2056
2057    As with `diff', several solutions are possible.  When comparing the
2058 files `A', `B', and `C', `diff3' normally finds `diff3' hunks by
2059 merging the two-way hunks output by the two commands `diff A B' and
2060 `diff A C'.  This does not necessarily minimize the size of the output,
2061 but exceptions should be rare.
2062
2063    For example, suppose `F' contains the three lines `a', `b', `f', `G'
2064 contains the lines `g', `b', `g', and `H' contains the lines `a', `b',
2065 `h'.  `diff3 F G H' might output the following:
2066
2067      ====2
2068      1:1c
2069      3:1c
2070        a
2071      2:1c
2072        g
2073      ====
2074      1:3c
2075        f
2076      2:3c
2077        g
2078      3:3c
2079        h
2080
2081 because it found a two-way hunk containing `a' in the first and third
2082 files and `g' in the second file, then the single line `b' common to
2083 all three files, then a three-way hunk containing the last line of each
2084 file.
2085
2086 \1f
2087 File: diff.info,  Node: diff3 Merging,  Next: Interactive Merging,  Prev: Comparing Three Files,  Up: Top
2088
2089 8 Merging From a Common Ancestor
2090 ********************************
2091
2092 When two people have made changes to copies of the same file, `diff3'
2093 can produce a merged output that contains both sets of changes together
2094 with warnings about conflicts.
2095
2096    One might imagine programs with names like `diff4' and `diff5' to
2097 compare more than three files simultaneously, but in practice the need
2098 rarely arises.  You can use `diff3' to merge three or more sets of
2099 changes to a file by merging two change sets at a time.
2100
2101    `diff3' can incorporate changes from two modified versions into a
2102 common preceding version.  This lets you merge the sets of changes
2103 represented by the two newer files.  Specify the common ancestor version
2104 as the second argument and the two newer versions as the first and third
2105 arguments, like this:
2106
2107      diff3 MINE OLDER YOURS
2108
2109 You can remember the order of the arguments by noting that they are in
2110 alphabetical order.
2111
2112    You can think of this as subtracting OLDER from YOURS and adding the
2113 result to MINE, or as merging into MINE the changes that would turn
2114 OLDER into YOURS.  This merging is well-defined as long as MINE and
2115 OLDER match in the neighborhood of each such change.  This fails to be
2116 true when all three input files differ or when only OLDER differs; we
2117 call this a "conflict".  When all three input files differ, we call the
2118 conflict an "overlap".
2119
2120    `diff3' gives you several ways to handle overlaps and conflicts.
2121 You can omit overlaps or conflicts, or select only overlaps, or mark
2122 conflicts with special `<<<<<<<' and `>>>>>>>' lines.
2123
2124    `diff3' can output the merge results as an `ed' script that that can
2125 be applied to the first file to yield the merged output.  However, it
2126 is usually better to have `diff3' generate the merged output directly;
2127 this bypasses some problems with `ed'.
2128
2129 * Menu:
2130
2131 * Which Changes::            Selecting changes to incorporate.
2132 * Marking Conflicts::        Marking conflicts.
2133 * Bypassing ed::             Generating merged output directly.
2134 * Merging Incomplete Lines:: How `diff3' merges incomplete lines.
2135 * Saving the Changed File::  Emulating System V behavior.
2136
2137 \1f
2138 File: diff.info,  Node: Which Changes,  Next: Marking Conflicts,  Up: diff3 Merging
2139
2140 8.1 Selecting Which Changes to Incorporate
2141 ==========================================
2142
2143 You can select all unmerged changes from OLDER to YOURS for merging
2144 into MINE with the `-e' or `--ed' option.  You can select only the
2145 nonoverlapping unmerged changes with `-3' or `--easy-only', and you can
2146 select only the overlapping changes with `-x' or `--overlap-only'.
2147
2148    The `-e', `-3' and `-x' options select only "unmerged changes", i.e.
2149 changes where MINE and YOURS differ; they ignore changes from OLDER to
2150 YOURS where MINE and YOURS are identical, because they assume that such
2151 changes have already been merged.  If this assumption is not a safe
2152 one, you can use the `-A' or `--show-all' option (*note Marking
2153 Conflicts::).
2154
2155    Here is the output of the command `diff3' with each of these three
2156 options (*note Sample diff3 Input::, for the complete contents of the
2157 files).  Notice that `-e' outputs the union of the disjoint sets of
2158 changes output by `-3' and `-x'.
2159
2160    Output of `diff3 -e lao tzu tao':
2161      11a
2162
2163        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2164      .
2165      8c
2166        so we may see their result.
2167      .
2168
2169    Output of `diff3 -3 lao tzu tao':
2170      8c
2171        so we may see their result.
2172      .
2173
2174    Output of `diff3 -x lao tzu tao':
2175      11a
2176
2177        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2178      .
2179
2180 \1f
2181 File: diff.info,  Node: Marking Conflicts,  Next: Bypassing ed,  Prev: Which Changes,  Up: diff3 Merging
2182
2183 8.2 Marking Conflicts
2184 =====================
2185
2186 `diff3' can mark conflicts in the merged output by bracketing them with
2187 special marker lines.  A conflict that comes from two files A and B is
2188 marked as follows:
2189
2190      <<<<<<< A
2191      lines from A
2192      =======
2193      lines from B
2194      >>>>>>> B
2195
2196    A conflict that comes from three files A, B and C is marked as
2197 follows:
2198
2199      <<<<<<< A
2200      lines from A
2201      ||||||| B
2202      lines from B
2203      =======
2204      lines from C
2205      >>>>>>> C
2206
2207    The `-A' or `--show-all' option acts like the `-e' option, except
2208 that it brackets conflicts, and it outputs all changes from OLDER to
2209 YOURS, not just the unmerged changes.  Thus, given the sample input
2210 files (*note Sample diff3 Input::), `diff3 -A lao tzu tao' puts
2211 brackets around the conflict where only `tzu' differs:
2212
2213      <<<<<<< tzu
2214      =======
2215      The Way that can be told of is not the eternal Way;
2216      The name that can be named is not the eternal name.
2217      >>>>>>> tao
2218
2219    And it outputs the three-way conflict as follows:
2220
2221      <<<<<<< lao
2222      ||||||| tzu
2223      They both may be called deep and profound.
2224      Deeper and more profound,
2225      The door of all subtleties!
2226      =======
2227
2228        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2229      >>>>>>> tao
2230
2231    The `-E' or `--show-overlap' option outputs less information than
2232 the `-A' or `--show-all' option, because it outputs only unmerged
2233 changes, and it never outputs the contents of the second file.  Thus
2234 the `-E' option acts like the `-e' option, except that it brackets the
2235 first and third files from three-way overlapping changes.  Similarly,
2236 `-X' acts like `-x', except it brackets all its (necessarily
2237 overlapping) changes.  For example, for the three-way overlapping
2238 change above, the `-E' and `-X' options output the following:
2239
2240      <<<<<<< lao
2241      =======
2242
2243        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2244      >>>>>>> tao
2245
2246    If you are comparing files that have meaningless or uninformative
2247 names, you can use the `--label=LABEL' option to show alternate names
2248 in the `<<<<<<<', `|||||||' and `>>>>>>>' brackets.  This option can be
2249 given up to three times, once for each input file.  Thus `diff3 -A
2250 --label X --label Y --label Z A B C' acts like `diff3 -A A B C', except
2251 that the output looks like it came from files named `X', `Y' and `Z'
2252 rather than from files named `A', `B' and `C'.
2253
2254 \1f
2255 File: diff.info,  Node: Bypassing ed,  Next: Merging Incomplete Lines,  Prev: Marking Conflicts,  Up: diff3 Merging
2256
2257 8.3 Generating the Merged Output Directly
2258 =========================================
2259
2260 With the `-m' or `--merge' option, `diff3' outputs the merged file
2261 directly.  This is more efficient than using `ed' to generate it, and
2262 works even with non-text files that `ed' would reject.  If you specify
2263 `-m' without an `ed' script option, `-A' is assumed.
2264
2265    For example, the command `diff3 -m lao tzu tao' (*note Sample diff3
2266 Input:: for a copy of the input files) would output the following:
2267
2268      <<<<<<< tzu
2269      =======
2270      The Way that can be told of is not the eternal Way;
2271      The name that can be named is not the eternal name.
2272      >>>>>>> tao
2273      The Nameless is the origin of Heaven and Earth;
2274      The Named is the mother of all things.
2275      Therefore let there always be non-being,
2276        so we may see their subtlety,
2277      And let there always be being,
2278        so we may see their result.
2279      The two are the same,
2280      But after they are produced,
2281        they have different names.
2282      <<<<<<< lao
2283      ||||||| tzu
2284      They both may be called deep and profound.
2285      Deeper and more profound,
2286      The door of all subtleties!
2287      =======
2288
2289        -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2290      >>>>>>> tao
2291
2292 \1f
2293 File: diff.info,  Node: Merging Incomplete Lines,  Next: Saving the Changed File,  Prev: Bypassing ed,  Up: diff3 Merging
2294
2295 8.4 How `diff3' Merges Incomplete Lines
2296 =======================================
2297
2298 With `-m', incomplete lines (*note Incomplete Lines::) are simply
2299 copied to the output as they are found; if the merged output ends in an
2300 conflict and one of the input files ends in an incomplete line,
2301 succeeding `|||||||', `=======' or `>>>>>>>' brackets appear somewhere
2302 other than the start of a line because they are appended to the
2303 incomplete line.
2304
2305    Without `-m', if an `ed' script option is specified and an
2306 incomplete line is found, `diff3' generates a warning and acts as if a
2307 newline had been present.
2308
2309 \1f
2310 File: diff.info,  Node: Saving the Changed File,  Prev: Merging Incomplete Lines,  Up: diff3 Merging
2311
2312 8.5 Saving the Changed File
2313 ===========================
2314
2315 Traditional Unix `diff3' generates an `ed' script without the trailing
2316 `w' and `q' commands that save the changes.  System V `diff3' generates
2317 these extra commands.  GNU `diff3' normally behaves like traditional
2318 Unix `diff3', but with the `-i' option it behaves like System V `diff3'
2319 and appends the `w' and `q' commands.
2320
2321    The `-i' option requires one of the `ed' script options `-AeExX3',
2322 and is incompatible with the merged output option `-m'.
2323
2324 \1f
2325 File: diff.info,  Node: Interactive Merging,  Next: Merging with patch,  Prev: diff3 Merging,  Up: Top
2326
2327 9 Interactive Merging with `sdiff'
2328 **********************************
2329
2330 With `sdiff', you can merge two files interactively based on a
2331 side-by-side `-y' format comparison (*note Side by Side::).  Use `-o
2332 FILE' or `--output=FILE' to specify where to put the merged text.
2333 *Note Invoking sdiff::, for more details on the options to `sdiff'.
2334
2335    Another way to merge files interactively is to use the Emacs Lisp
2336 package `emerge'.  *Note emerge: (emacs)emerge, for more information.
2337
2338 * Menu:
2339
2340 * sdiff Option Summary:: Summary of `sdiff' options.
2341 * Merge Commands::       Merging two files interactively.
2342
2343 \1f
2344 File: diff.info,  Node: sdiff Option Summary,  Next: Merge Commands,  Up: Interactive Merging
2345
2346 9.1 Specifying `diff' Options to `sdiff'
2347 ========================================
2348
2349 The following `sdiff' options have the same meaning as for `diff'.
2350 *Note diff Options::, for the use of these options.
2351
2352      -a -b -d -i -t -v
2353      -B -E -I REGEXP
2354
2355      --expand-tabs
2356      --ignore-blank-lines  --ignore-case
2357      --ignore-matching-lines=REGEXP  --ignore-space-change
2358      --ignore-tab-expansion
2359      --left-column  --minimal  --speed-large-files
2360      --strip-trailing-cr  --suppress-common-lines
2361      --tabsize=COLUMNS  --text  --version  --width=COLUMNS
2362
2363    For historical reasons, `sdiff' has alternate names for some
2364 options.  The `-l' option is equivalent to the `--left-column' option,
2365 and similarly `-s' is equivalent to `--suppress-common-lines'.  The
2366 meaning of the `sdiff' `-w' and `-W' options is interchanged from that
2367 of `diff': with `sdiff', `-w COLUMNS' is equivalent to
2368 `--width=COLUMNS', and `-W' is equivalent to `--ignore-all-space'.
2369 `sdiff' without the `-o' option is equivalent to `diff' with the `-y'
2370 or `--side-by-side' option (*note Side by Side::).
2371
2372 \1f
2373 File: diff.info,  Node: Merge Commands,  Prev: sdiff Option Summary,  Up: Interactive Merging
2374
2375 9.2 Merge Commands
2376 ==================
2377
2378 Groups of common lines, with a blank gutter, are copied from the first
2379 file to the output.  After each group of differing lines, `sdiff'
2380 prompts with `%' and pauses, waiting for one of the following commands.
2381 Follow each command with <RET>.
2382
2383 `e'
2384      Discard both versions.  Invoke a text editor on an empty temporary
2385      file, then copy the resulting file to the output.
2386
2387 `eb'
2388      Concatenate the two versions, edit the result in a temporary file,
2389      then copy the edited result to the output.
2390
2391 `ed'
2392      Like `eb', except precede each version with a header that shows
2393      what file and lines the version came from.
2394
2395 `el'
2396 `e1'
2397      Edit a copy of the left version, then copy the result to the
2398      output.
2399
2400 `er'
2401 `e2'
2402      Edit a copy of the right version, then copy the result to the
2403      output.
2404
2405 `l'
2406 `1'
2407      Copy the left version to the output.
2408
2409 `q'
2410      Quit.
2411
2412 `r'
2413 `2'
2414      Copy the right version to the output.
2415
2416 `s'
2417      Silently copy common lines.
2418
2419 `v'
2420      Verbosely copy common lines.  This is the default.
2421
2422    The text editor invoked is specified by the `EDITOR' environment
2423 variable if it is set.  The default is system-dependent.
2424
2425 \1f
2426 File: diff.info,  Node: Merging with patch,  Next: Making Patches,  Prev: Interactive Merging,  Up: Top
2427
2428 10 Merging with `patch'
2429 ***********************
2430
2431 `patch' takes comparison output produced by `diff' and applies the
2432 differences to a copy of the original file, producing a patched
2433 version.  With `patch', you can distribute just the changes to a set of
2434 files instead of distributing the entire file set; your correspondents
2435 can apply `patch' to update their copy of the files with your changes.
2436 `patch' automatically determines the diff format, skips any leading or
2437 trailing headers, and uses the headers to determine which file to
2438 patch.  This lets your correspondents feed a mail message containing a
2439 difference listing directly to `patch'.
2440
2441    `patch' detects and warns about common problems like forward
2442 patches.  It saves any patches that it could not apply.  It can also
2443 maintain a `patchlevel.h' file to ensure that your correspondents apply
2444 diffs in the proper order.
2445
2446    `patch' accepts a series of diffs in its standard input, usually
2447 separated by headers that specify which file to patch.  It applies
2448 `diff' hunks (*note Hunks::) one by one.  If a hunk does not exactly
2449 match the original file, `patch' uses heuristics to try to patch the
2450 file as well as it can.  If no approximate match can be found, `patch'
2451 rejects the hunk and skips to the next hunk.  `patch' normally replaces
2452 each file F with its new version, putting reject hunks (if any) into
2453 `F.rej'.
2454
2455    *Note Invoking patch::, for detailed information on the options to
2456 `patch'.
2457
2458 * Menu:
2459
2460 * patch Input::            Selecting the type of `patch' input.
2461 * Revision Control::       Getting files from RCS, SCCS, etc.
2462 * Imperfect::              Dealing with imperfect patches.
2463 * Creating and Removing::  Creating and removing files with a patch.
2464 * Patching Time Stamps::   Updating time stamps on patched files.
2465 * Multiple Patches::       Handling multiple patches in a file.
2466 * patch Directories::      Changing directory and stripping directories.
2467 * Backups::                Whether backup files are made.
2468 * Backup Names::           Backup file names.
2469 * Reject Names::           Reject file names.
2470 * patch Messages::         Messages and questions `patch' can produce.
2471 * patch and POSIX::        Conformance to the POSIX standard.
2472 * patch and Tradition::    GNU versus traditional `patch'.
2473
2474 \1f
2475 File: diff.info,  Node: patch Input,  Next: Revision Control,  Up: Merging with patch
2476
2477 10.1 Selecting the `patch' Input Format
2478 =======================================
2479
2480 `patch' normally determines which `diff' format the patch file uses by
2481 examining its contents.  For patch files that contain particularly
2482 confusing leading text, you might need to use one of the following
2483 options to force `patch' to interpret the patch file as a certain
2484 format of diff.  The output formats listed here are the only ones that
2485 `patch' can understand.
2486
2487 `-c'
2488 `--context'
2489      context diff.
2490
2491 `-e'
2492 `--ed'
2493      `ed' script.
2494
2495 `-n'
2496 `--normal'
2497      normal diff.
2498
2499 `-u'
2500 `--unified'
2501      unified diff.
2502
2503 \1f
2504 File: diff.info,  Node: Revision Control,  Next: Imperfect,  Prev: patch Input,  Up: Merging with patch
2505
2506 10.2 Revision Control
2507 =====================
2508
2509 If a nonexistent input file is under a revision control system
2510 supported by `patch', `patch' normally asks the user whether to get (or
2511 check out) the file from the revision control system.  Patch currently
2512 supports RCS, ClearCase and SCCS.  Under RCS and SCCS, `patch' also
2513 asks when the input file is read-only and matches the default version
2514 in the revision control system.
2515
2516    The `-g NUM' or `--get=NUM' option affects access to files under
2517 supported revision control systems.  If NUM is positive, `patch' gets
2518 the file without asking the user; if zero, `patch' neither asks the
2519 user nor gets the file; and if negative, `patch' asks the user before
2520 getting the file.  The default value of NUM is given by the value of the
2521 `PATCH_GET' environment variable if it is set; if not, the default
2522 value is zero if `patch' is conforming to POSIX, negative otherwise.
2523 *Note patch and POSIX::.
2524
2525    The choice of revision control system is unaffected by the
2526 `VERSION_CONTROL' environment variable (*note Backup Names::).
2527
2528 \1f
2529 File: diff.info,  Node: Imperfect,  Next: Creating and Removing,  Prev: Revision Control,  Up: Merging with patch
2530
2531 10.3 Applying Imperfect Patches
2532 ===============================
2533
2534 `patch' tries to skip any leading text in the patch file, apply the
2535 diff, and then skip any trailing text.  Thus you can feed a mail
2536 message directly to `patch', and it should work.  If the entire diff is
2537 indented by a constant amount of white space, `patch' automatically
2538 ignores the indentation.  If a context diff contains trailing carriage
2539 return on each line, `patch' automatically ignores the carriage return.
2540 If a context diff has been encapsulated by prepending `- ' to lines
2541 beginning with `-' as per Internet RFC 934
2542 (ftp://ftp.isi.edu/in-notes/rfc934.txt), `patch' automatically
2543 unencapsulates the input.
2544
2545    However, certain other types of imperfect input require user
2546 intervention or testing.
2547
2548 * Menu:
2549
2550 * Changed White Space:: When tabs and spaces don't match exactly.
2551 * Reversed Patches::    Applying reversed patches correctly.
2552 * Inexact::             Helping `patch' find close matches.
2553 * Dry Runs::            Predicting what `patch' will do.
2554
2555 \1f
2556 File: diff.info,  Node: Changed White Space,  Next: Reversed Patches,  Up: Imperfect
2557
2558 10.3.1 Applying Patches with Changed White Space
2559 ------------------------------------------------
2560
2561 Sometimes mailers, editors, or other programs change spaces into tabs,
2562 or vice versa.  If this happens to a patch file or an input file, the
2563 files might look the same, but `patch' will not be able to match them
2564 properly.  If this problem occurs, use the `-l' or
2565 `--ignore-white-space' option, which makes `patch' compare blank
2566 characters (i.e. spaces and tabs) loosely so that any nonempty sequence
2567 of blanks in the patch file matches any nonempty sequence of blanks in
2568 the input files.  Non-blank characters must still match exactly.  Each
2569 line of the context must still match a line in the input file.
2570
2571 \1f
2572 File: diff.info,  Node: Reversed Patches,  Next: Inexact,  Prev: Changed White Space,  Up: Imperfect
2573
2574 10.3.2 Applying Reversed Patches
2575 --------------------------------
2576
2577 Sometimes people run `diff' with the new file first instead of second.
2578 This creates a diff that is "reversed".  To apply such patches, give
2579 `patch' the `-R' or `--reverse' option.  `patch' then attempts to swap
2580 each hunk around before applying it.  Rejects come out in the swapped
2581 format.
2582
2583    Often `patch' can guess that the patch is reversed.  If the first
2584 hunk of a patch fails, `patch' reverses the hunk to see if it can apply
2585 it that way.  If it can, `patch' asks you if you want to have the `-R'
2586 option set; if it can't, `patch' continues to apply the patch normally.
2587 This method cannot detect a reversed patch if it is a normal diff and
2588 the first command is an append (which should have been a delete) since
2589 appends always succeed, because a null context matches anywhere.  But
2590 most patches add or change lines rather than delete them, so most
2591 reversed normal diffs begin with a delete, which fails, and `patch'
2592 notices.
2593
2594    If you apply a patch that you have already applied, `patch' thinks
2595 it is a reversed patch and offers to un-apply the patch.  This could be
2596 construed as a feature.  If you did this inadvertently and you don't
2597 want to un-apply the patch, just answer `n' to this offer and to the
2598 subsequent "apply anyway" question--or type `C-c' to kill the `patch'
2599 process.
2600
2601 \1f
2602 File: diff.info,  Node: Inexact,  Next: Dry Runs,  Prev: Reversed Patches,  Up: Imperfect
2603
2604 10.3.3 Helping `patch' Find Inexact Matches
2605 -------------------------------------------
2606
2607 For context diffs, and to a lesser extent normal diffs, `patch' can
2608 detect when the line numbers mentioned in the patch are incorrect, and
2609 it attempts to find the correct place to apply each hunk of the patch.
2610 As a first guess, it takes the line number mentioned in the hunk, plus
2611 or minus any offset used in applying the previous hunk.  If that is not
2612 the correct place, `patch' scans both forward and backward for a set of
2613 lines matching the context given in the hunk.
2614
2615    First `patch' looks for a place where all lines of the context
2616 match.  If it cannot find such a place, and it is reading a context or
2617 unified diff, and the maximum fuzz factor is set to 1 or more, then
2618 `patch' makes another scan, ignoring the first and last line of
2619 context.  If that fails, and the maximum fuzz factor is set to 2 or
2620 more, it makes another scan, ignoring the first two and last two lines
2621 of context are ignored.  It continues similarly if the maximum fuzz
2622 factor is larger.
2623
2624    The `-F LINES' or `--fuzz=LINES' option sets the maximum fuzz factor
2625 to LINES.  This option only applies to context and unified diffs; it
2626 ignores up to LINES lines while looking for the place to install a
2627 hunk.  Note that a larger fuzz factor increases the odds of making a
2628 faulty patch.  The default fuzz factor is 2; there is no point to
2629 setting it to more than the number of lines of context in the diff,
2630 ordinarily 3.
2631
2632    If `patch' cannot find a place to install a hunk of the patch, it
2633 writes the hunk out to a reject file (*note Reject Names::, for
2634 information on how reject files are named).  It writes out rejected
2635 hunks in context format no matter what form the input patch is in.  If
2636 the input is a normal or `ed' diff, many of the contexts are simply
2637 null.  The line numbers on the hunks in the reject file may be
2638 different from those in the patch file: they show the approximate
2639 location where `patch' thinks the failed hunks belong in the new file
2640 rather than in the old one.
2641
2642    If the `--verbose' option is given, then as it completes each hunk
2643 `patch' tells you whether the hunk succeeded or failed, and if it
2644 failed, on which line (in the new file) `patch' thinks the hunk should
2645 go.  If this is different from the line number specified in the diff,
2646 it tells you the offset.  A single large offset _may_ indicate that
2647 `patch' installed a hunk in the wrong place.  `patch' also tells you if
2648 it used a fuzz factor to make the match, in which case you should also
2649 be slightly suspicious.
2650
2651    `patch' cannot tell if the line numbers are off in an `ed' script,
2652 and can only detect wrong line numbers in a normal diff when it finds a
2653 change or delete command.  It may have the same problem with a context
2654 diff using a fuzz factor equal to or greater than the number of lines
2655 of context shown in the diff (typically 3).  In these cases, you should
2656 probably look at a context diff between your original and patched input
2657 files to see if the changes make sense.  Compiling without errors is a
2658 pretty good indication that the patch worked, but not a guarantee.
2659
2660    A patch against an empty file applies to a nonexistent file, and vice
2661 versa.  *Note Creating and Removing::.
2662
2663    `patch' usually produces the correct results, even when it must make
2664 many guesses.  However, the results are guaranteed only when the patch
2665 is applied to an exact copy of the file that the patch was generated
2666 from.
2667
2668 \1f
2669 File: diff.info,  Node: Dry Runs,  Prev: Inexact,  Up: Imperfect
2670
2671 10.3.4 Predicting what `patch' will do
2672 --------------------------------------
2673
2674 It may not be obvious in advance what `patch' will do with a
2675 complicated or poorly formatted patch.  If you are concerned that the
2676 input might cause `patch' to modify the wrong files, you can use the
2677 `--dry-run' option, which causes `patch' to print the results of
2678 applying patches without actually changing any files.  You can then
2679 inspect the diagnostics generated by the dry run to see whether `patch'
2680 will modify the files that you expect.  If the patch does not do what
2681 you want, you can modify the patch (or the other options to `patch')
2682 and try another dry run.  Once you are satisfied with the proposed
2683 patch you can apply it by invoking `patch' as before, but this time
2684 without the `--dry-run' option.
2685
2686 \1f
2687 File: diff.info,  Node: Creating and Removing,  Next: Patching Time Stamps,  Prev: Imperfect,  Up: Merging with patch
2688
2689 10.4 Creating and Removing Files
2690 ================================
2691
2692 Sometimes when comparing two directories, a file may exist in one
2693 directory but not the other.  If you give `diff' the `-N' or
2694 `--new-file' option, or if you supply an old or new file that is named
2695 `/dev/null' or is empty and is dated the Epoch (1970-01-01 00:00:00
2696 UTC), `diff' outputs a patch that adds or deletes the contents of this
2697 file.  When given such a patch, `patch' normally creates a new file or
2698 removes the old file.  However, when conforming to POSIX (*note patch
2699 and POSIX::), `patch' does not remove the old file, but leaves it empty.
2700 The `-E' or `--remove-empty-files' option causes `patch' to remove
2701 output files that are empty after applying a patch, even if the patch
2702 does not appear to be one that removed the file.
2703
2704    If the patch appears to create a file that already exists, `patch'
2705 asks for confirmation before applying the patch.
2706
2707 \1f
2708 File: diff.info,  Node: Patching Time Stamps,  Next: Multiple Patches,  Prev: Creating and Removing,  Up: Merging with patch
2709
2710 10.5 Updating Time Stamps on Patched Files
2711 ==========================================
2712
2713 When `patch' updates a file, it normally sets the file's last-modified
2714 time stamp to the current time of day.  If you are using `patch' to
2715 track a software distribution, this can cause `make' to incorrectly
2716 conclude that a patched file is out of date.  For example, if
2717 `syntax.c' depends on `syntax.y', and `patch' updates `syntax.c' and
2718 then `syntax.y', then `syntax.c' will normally appear to be out of date
2719 with respect to `syntax.y' even though its contents are actually up to
2720 date.
2721
2722    The `-Z' or `--set-utc' option causes `patch' to set a patched
2723 file's modification and access times to the time stamps given in
2724 context diff headers.  If the context diff headers do not specify a
2725 time zone, they are assumed to use Coordinated Universal Time (UTC,
2726 often known as GMT).
2727
2728    The `-T' or `--set-time' option acts like `-Z' or `--set-utc',
2729 except that it assumes that the context diff headers' time stamps use
2730 local time instead of UTC.  This option is not recommended, because
2731 patches using local time cannot easily be used by people in other time
2732 zones, and because local time stamps are ambiguous when local clocks
2733 move backwards during daylight-saving time adjustments.  If the context
2734 diff headers specify a time zone, this option is equivalent to `-Z' or
2735 `--set-utc'.
2736
2737    `patch' normally refrains from setting a file's time stamps if the
2738 file's original last-modified time stamp does not match the time given
2739 in the diff header, of if the file's contents do not exactly match the
2740 patch.  However, if the `-f' or `--force' option is given, the file's
2741 time stamps are set regardless.
2742
2743    Due to the limitations of the current `diff' format, `patch' cannot
2744 update the times of files whose contents have not changed.  Also, if
2745 you set file time stamps to values other than the current time of day,
2746 you should also remove (e.g., with `make clean') all files that depend
2747 on the patched files, so that later invocations of `make' do not get
2748 confused by the patched files' times.
2749
2750 \1f
2751 File: diff.info,  Node: Multiple Patches,  Next: patch Directories,  Prev: Patching Time Stamps,  Up: Merging with patch
2752
2753 10.6 Multiple Patches in a File
2754 ===============================
2755
2756 If the patch file contains more than one patch, and if you do not
2757 specify an input file on the command line, `patch' tries to apply each
2758 patch as if they came from separate patch files.  This means that it
2759 determines the name of the file to patch for each patch, and that it
2760 examines the leading text before each patch for file names and
2761 prerequisite revision level (*note Making Patches::, for more on that
2762 topic).
2763
2764    `patch' uses the following rules to intuit a file name from the
2765 leading text before a patch.  First, `patch' takes an ordered list of
2766 candidate file names as follows:
2767
2768    * If the header is that of a context diff, `patch' takes the old and
2769      new file names in the header.  A name is ignored if it does not
2770      have enough slashes to satisfy the `-pNUM' or `--strip=NUM'
2771      option.  The name `/dev/null' is also ignored.
2772
2773    * If there is an `Index:' line in the leading garbage and if either
2774      the old and new names are both absent or if `patch' is conforming
2775      to POSIX, `patch' takes the name in the `Index:' line.
2776
2777    * For the purpose of the following rules, the candidate file names
2778      are considered to be in the order (old, new, index), regardless of
2779      the order that they appear in the header.
2780
2781 Then `patch' selects a file name from the candidate list as follows:
2782
2783    * If some of the named files exist, `patch' selects the first name
2784      if conforming to POSIX, and the best name otherwise.
2785
2786    * If `patch' is not ignoring RCS, ClearCase, and SCCS (*note
2787      Revision Control::), and no named files exist but an RCS,
2788      ClearCase, or SCCS master is found, `patch' selects the first
2789      named file with an RCS, ClearCase, or SCCS master.
2790
2791    * If no named files exist, no RCS, ClearCase, or SCCS master was
2792      found, some names are given, `patch' is not conforming to POSIX,
2793      and the patch appears to create a file, `patch' selects the best
2794      name requiring the creation of the fewest directories.
2795
2796    * If no file name results from the above heuristics, you are asked
2797      for the name of the file to patch, and `patch' selects that name.
2798
2799    To determine the "best" of a nonempty list of file names, `patch'
2800 first takes all the names with the fewest path name components; of
2801 those, it then takes all the names with the shortest basename; of
2802 those, it then takes all the shortest names; finally, it takes the
2803 first remaining name.
2804
2805    *Note patch and POSIX::, to see whether `patch' is conforming to
2806 POSIX.
2807
2808 \1f
2809 File: diff.info,  Node: patch Directories,  Next: Backups,  Prev: Multiple Patches,  Up: Merging with patch
2810
2811 10.7 Applying Patches in Other Directories
2812 ==========================================
2813
2814 The `-d DIRECTORY' or `--directory=DIRECTORY' option to `patch' makes
2815 directory DIRECTORY the current directory for interpreting both file
2816 names in the patch file, and file names given as arguments to other
2817 options (such as `-B' and `-o').  For example, while in a mail reading
2818 program, you can patch a file in the `/usr/src/emacs' directory
2819 directly from a message containing the patch like this:
2820
2821      | patch -d /usr/src/emacs
2822
2823    Sometimes the file names given in a patch contain leading
2824 directories, but you keep your files in a directory different from the
2825 one given in the patch.  In those cases, you can use the `-pNUMBER' or
2826 `--strip=NUMBER' option to set the file name strip count to NUMBER.
2827 The strip count tells `patch' how many slashes, along with the directory
2828 names between them, to strip from the front of file names.  A sequence
2829 of one or more adjacent slashes is counted as a single slash.  By
2830 default, `patch' strips off all leading directories, leaving just the
2831 base file names.
2832
2833    For example, suppose the file name in the patch file is
2834 `/gnu/src/emacs/etc/NEWS'.  Using `-p0' gives the entire file name
2835 unmodified, `-p1' gives `gnu/src/emacs/etc/NEWS' (no leading slash),
2836 `-p4' gives `etc/NEWS', and not specifying `-p' at all gives `NEWS'.
2837
2838    `patch' looks for each file (after any slashes have been stripped)
2839 in the current directory, or if you used the `-d DIRECTORY' option, in
2840 that directory.
2841
2842 \1f
2843 File: diff.info,  Node: Backups,  Next: Backup Names,  Prev: patch Directories,  Up: Merging with patch
2844
2845 10.8 Backup Files
2846 =================
2847
2848 Normally, `patch' creates a backup file if the patch does not exactly
2849 match the original input file, because in that case the original data
2850 might not be recovered if you undo the patch with `patch -R' (*note
2851 Reversed Patches::).  However, when conforming to POSIX, `patch' does
2852 not create backup files by default.  *Note patch and POSIX::.
2853
2854    The `-b' or `--backup' option causes `patch' to make a backup file
2855 regardless of whether the patch matches the original input.  The
2856 `--backup-if-mismatch' option causes `patch' to create backup files for
2857 mismatches files; this is the default when not conforming to POSIX.  The
2858 `--no-backup-if-mismatch' option causes `patch' to not create backup
2859 files, even for mismatched patches; this is the default when conforming
2860 to POSIX.
2861
2862    When backing up a file that does not exist, an empty, unreadable
2863 backup file is created as a placeholder to represent the nonexistent
2864 file.
2865
2866 \1f
2867 File: diff.info,  Node: Backup Names,  Next: Reject Names,  Prev: Backups,  Up: Merging with patch
2868
2869 10.9 Backup File Names
2870 ======================
2871
2872 Normally, `patch' renames an original input file into a backup file by
2873 appending to its name the extension `.orig', or `~' if using `.orig'
2874 would make the backup file name too long.(1)  The `-z BACKUP-SUFFIX' or
2875 `--suffix=BACKUP-SUFFIX' option causes `patch' to use BACKUP-SUFFIX as
2876 the backup extension instead.
2877
2878    Alternately, you can specify the extension for backup files with the
2879 `SIMPLE_BACKUP_SUFFIX' environment variable, which the options override.
2880
2881    `patch' can also create numbered backup files the way GNU Emacs
2882 does.  With this method, instead of having a single backup of each
2883 file, `patch' makes a new backup file name each time it patches a file.
2884 For example, the backups of a file named `sink' would be called,
2885 successively, `sink.~1~', `sink.~2~', `sink.~3~', etc.
2886
2887    The `-V BACKUP-STYLE' or `--version-control=BACKUP-STYLE' option
2888 takes as an argument a method for creating backup file names.  You can
2889 alternately control the type of backups that `patch' makes with the
2890 `PATCH_VERSION_CONTROL' environment variable, which the `-V' option
2891 overrides.  If `PATCH_VERSION_CONTROL' is not set, the
2892 `VERSION_CONTROL' environment variable is used instead.  Please note
2893 that these options and variables control backup file names; they do not
2894 affect the choice of revision control system (*note Revision Control::).
2895
2896    The values of these environment variables and the argument to the
2897 `-V' option are like the GNU Emacs `version-control' variable (*note
2898 Backup Names: (emacs)Backup Names, for more information on backup
2899 versions in Emacs).  They also recognize synonyms that are more
2900 descriptive.  The valid values are listed below; unique abbreviations
2901 are acceptable.
2902
2903 `t'
2904 `numbered'
2905      Always make numbered backups.
2906
2907 `nil'
2908 `existing'
2909      Make numbered backups of files that already have them, simple
2910      backups of the others.  This is the default.
2911
2912 `never'
2913 `simple'
2914      Always make simple backups.
2915
2916    You can also tell `patch' to prepend a prefix, such as a directory
2917 name, to produce backup file names.  The `-B PREFIX' or
2918 `--prefix=PREFIX' option makes backup files by prepending PREFIX to
2919 them.  The `-Y PREFIX' or `--basename-prefix=PREFIX' prepends PREFIX to
2920 the last file name component of backup file names instead; for example,
2921 `-Y ~' causes the backup name for `dir/file.c' to be `dir/~file.c'.  If
2922 you use either of these prefix options, the suffix-based options are
2923 ignored.
2924
2925    If you specify the output file with the `-o' option, that file is
2926 the one that is backed up, not the input file.
2927
2928    Options that affect the names of backup files do not affect whether
2929 backups are made.  For example, if you specify the
2930 `--no-backup-if-mismatch' option, none of the options described in this
2931 section have any affect, because no backups are made.
2932
2933    ---------- Footnotes ----------
2934
2935    (1) A coding error in GNU `patch' version 2.5.4 causes it to always
2936 use `~', but this should be fixed in the next release.
2937
2938 \1f
2939 File: diff.info,  Node: Reject Names,  Next: patch Messages,  Prev: Backup Names,  Up: Merging with patch
2940
2941 10.10 Reject File Names
2942 =======================
2943
2944 The names for reject files (files containing patches that `patch' could
2945 not find a place to apply) are normally the name of the output file
2946 with `.rej' appended (or `#' if using `.rej' would make the backup file
2947 name too long).
2948
2949    Alternatively, you can tell `patch' to place all of the rejected
2950 patches in a single file.  The `-r REJECT-FILE' or
2951 `--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file
2952 name.
2953
2954 \1f
2955 File: diff.info,  Node: patch Messages,  Next: patch and POSIX,  Prev: Reject Names,  Up: Merging with patch
2956
2957 10.11 Messages and Questions from `patch'
2958 =========================================
2959
2960 `patch' can produce a variety of messages, especially if it has trouble
2961 decoding its input.  In a few situations where it's not sure how to
2962 proceed, `patch' normally prompts you for more information from the
2963 keyboard.  There are options to produce more or fewer messages, to have
2964 it not ask for keyboard input, and to affect the way that file names
2965 are quoted in messages.
2966
2967 * Menu:
2968
2969 * More or Fewer Messages::    Controlling the verbosity of `patch'.
2970 * patch and Keyboard Input::  Inhibiting keyboard input.
2971 * patch Quoting Style::       Quoting file names in diagnostics.
2972
2973    `patch' exits with status 0 if all hunks are applied successfully, 1
2974 if some hunks cannot be applied, and 2 if there is more serious trouble.
2975 When applying a set of patches in a loop, you should check the exit
2976 status, so you don't apply a later patch to a partially patched file.
2977
2978 \1f
2979 File: diff.info,  Node: More or Fewer Messages,  Next: patch and Keyboard Input,  Up: patch Messages
2980
2981 10.11.1 Controlling the Verbosity of `patch'
2982 --------------------------------------------
2983
2984 You can cause `patch' to produce more messages by using the `--verbose'
2985 option.  For example, when you give this option, the message `Hmm...'
2986 indicates that `patch' is reading text in the patch file, attempting to
2987 determine whether there is a patch in that text, and if so, what kind
2988 of patch it is.
2989
2990    You can inhibit all terminal output from `patch', unless an error
2991 occurs, by using the `-s', `--quiet', or `--silent' option.
2992
2993 \1f
2994 File: diff.info,  Node: patch and Keyboard Input,  Next: patch Quoting Style,  Prev: More or Fewer Messages,  Up: patch Messages
2995
2996 10.11.2 Inhibiting Keyboard Input
2997 ---------------------------------
2998
2999 There are two ways you can prevent `patch' from asking you any
3000 questions.  The `-f' or `--force' option assumes that you know what you
3001 are doing.  It causes `patch' to do the following:
3002
3003    * Skip patches that do not contain file names in their headers.
3004
3005    * Patch files even though they have the wrong version for the
3006      `Prereq:' line in the patch;
3007
3008    * Assume that patches are not reversed even if they look like they
3009      are.
3010
3011 The `-t' or `--batch' option is similar to `-f', in that it suppresses
3012 questions, but it makes somewhat different assumptions:
3013
3014    * Skip patches that do not contain file names in their headers (the
3015      same as `-f').
3016
3017    * Skip patches for which the file has the wrong version for the
3018      `Prereq:' line in the patch;
3019
3020    * Assume that patches are reversed if they look like they are.
3021
3022 \1f
3023 File: diff.info,  Node: patch Quoting Style,  Prev: patch and Keyboard Input,  Up: patch Messages
3024
3025 10.11.3 `patch' Quoting Style
3026 -----------------------------
3027
3028 When `patch' outputs a file name in a diagnostic message, it can format
3029 the name in any of several ways.  This can be useful to output file
3030 names unambiguously, even if they contain punctuation or special
3031 characters like newlines.  The `--quoting-style=WORD' option controls
3032 how names are output.  The WORD should be one of the following:
3033
3034 `literal'
3035      Output names as-is.
3036
3037 `shell'
3038      Quote names for the shell if they contain shell metacharacters or
3039      would cause ambiguous output.
3040
3041 `shell-always'
3042      Quote names for the shell, even if they would normally not require
3043      quoting.
3044
3045 `c'
3046      Quote names as for a C language string.
3047
3048 `escape'
3049      Quote as with `c' except omit the surrounding double-quote
3050      characters.
3051
3052    You can specify the default value of the `--quoting-style' option
3053 with the environment variable `QUOTING_STYLE'.  If that environment
3054 variable is not set, the default value is `shell', but this default may
3055 change in a future version of `patch'.
3056
3057 \1f
3058 File: diff.info,  Node: patch and POSIX,  Next: patch and Tradition,  Prev: patch Messages,  Up: Merging with patch
3059
3060 10.12 `patch' and the POSIX Standard
3061 ====================================
3062
3063 If you specify the `--posix' option, or set the `POSIXLY_CORRECT'
3064 environment variable, `patch' conforms more strictly to the POSIX
3065 standard, as follows:
3066
3067    * Take the first existing file from the list (old, new, index) when
3068      intuiting file names from diff headers.  *Note Multiple Patches::.
3069
3070    * Do not remove files that are removed by a diff.  *Note Creating
3071      and Removing::.
3072
3073    * Do not ask whether to get files from RCS, ClearCase, or SCCS.
3074      *Note Revision Control::.
3075
3076    * Require that all options precede the files in the command line.
3077
3078    * Do not backup files, even when there is a mismatch.  *Note
3079      Backups::.
3080
3081
3082 \1f
3083 File: diff.info,  Node: patch and Tradition,  Prev: patch and POSIX,  Up: Merging with patch
3084
3085 10.13 GNU `patch' and Traditional `patch'
3086 =========================================
3087
3088 The current version of GNU `patch' normally follows the POSIX standard.
3089 *Note patch and POSIX::, for the few exceptions to this general rule.
3090
3091    Unfortunately, POSIX redefined the behavior of `patch' in several
3092 important ways.  You should be aware of the following differences if
3093 you must interoperate with traditional `patch', or with GNU `patch'
3094 version 2.1 and earlier.
3095
3096    * In traditional `patch', the `-p' option's operand was optional,
3097      and a bare `-p' was equivalent to `-p0'.  The `-p' option now
3098      requires an operand, and `-p 0' is now equivalent to `-p0'.  For
3099      maximum compatibility, use options like `-p0' and `-p1'.
3100
3101      Also, traditional `patch' simply counted slashes when stripping
3102      path prefixes; `patch' now counts pathname components.  That is, a
3103      sequence of one or more adjacent slashes now counts as a single
3104      slash.  For maximum portability, avoid sending patches containing
3105      `//' in file names.
3106
3107    * In traditional `patch', backups were enabled by default.  This
3108      behavior is now enabled with the `-b' or `--backup' option.
3109
3110      Conversely, in POSIX `patch', backups are never made, even when
3111      there is a mismatch.  In GNU `patch', this behavior is enabled
3112      with the `--no-backup-if-mismatch' option, or by conforming to
3113      POSIX.
3114
3115      The `-b SUFFIX' option of traditional `patch' is equivalent to the
3116      `-b -z SUFFIX' options of GNU `patch'.
3117
3118    * Traditional `patch' used a complicated (and incompletely
3119      documented) method to intuit the name of the file to be patched
3120      from the patch header.  This method did not conform to POSIX, and
3121      had a few gotchas.  Now `patch' uses a different, equally
3122      complicated (but better documented) method that is optionally
3123      POSIX-conforming; we hope it has fewer gotchas.  The two methods
3124      are compatible if the file names in the context diff header and the
3125      `Index:' line are all identical after prefix-stripping.  Your
3126      patch is normally compatible if each header's file names all
3127      contain the same number of slashes.
3128
3129    * When traditional `patch' asked the user a question, it sent the
3130      question to standard error and looked for an answer from the first
3131      file in the following list that was a terminal: standard error,
3132      standard output, `/dev/tty', and standard input.  Now `patch'
3133      sends questions to standard output and gets answers from
3134      `/dev/tty'.  Defaults for some answers have been changed so that
3135      `patch' never goes into an infinite loop when using default
3136      answers.
3137
3138    * Traditional `patch' exited with a status value that counted the
3139      number of bad hunks, or with status 1 if there was real trouble.
3140      Now `patch' exits with status 1 if some hunks failed, or with 2 if
3141      there was real trouble.
3142
3143    * Limit yourself to the following options when sending instructions
3144      meant to be executed by anyone running GNU `patch', traditional
3145      `patch', or a `patch' that conforms to POSIX.  Spaces are
3146      significant in the following list, and operands are required.
3147
3148           `-c'
3149           `-d DIR'
3150           `-D DEFINE'
3151           `-e'
3152           `-l'
3153           `-n'
3154           `-N'
3155           `-o OUTFILE'
3156           `-pNUM'
3157           `-R'
3158           `-r REJECTFILE'
3159
3160
3161 \1f
3162 File: diff.info,  Node: Making Patches,  Next: Invoking cmp,  Prev: Merging with patch,  Up: Top
3163
3164 11 Tips for Making and Using Patches
3165 ************************************
3166
3167 Use some common sense when making and using patches.  For example, when
3168 sending bug fixes to a program's maintainer, send several small
3169 patches, one per independent subject, instead of one large,
3170 harder-to-digest patch that covers all the subjects.
3171
3172    Here are some other things you should keep in mind if you are going
3173 to distribute patches for updating a software package.
3174
3175 * Menu:
3176
3177 * Tips for Patch Producers::    Advice for making patches.
3178 * Tips for Patch Consumers::    Advice for using patches.
3179 * Avoiding Common Mistakes::    Avoiding common mistakes when using `patch'.
3180 * Generating Smaller Patches::  How to generate smaller patches.
3181
3182 \1f
3183 File: diff.info,  Node: Tips for Patch Producers,  Next: Tips for Patch Consumers,  Up: Making Patches
3184
3185 11.1 Tips for Patch Producers
3186 =============================
3187
3188 To create a patch that changes an older version of a package into a
3189 newer version, first make a copy of the older and newer versions in
3190 adjacent subdirectories.  It is common to do that by unpacking `tar'
3191 archives of the two versions.
3192
3193    To generate the patch, use the command `diff -Naur OLD NEW' where
3194 OLD and NEW identify the old and new directories.  The names OLD and
3195 NEW should not contain any slashes.  The `-N' option lets the patch
3196 create and remove files; `-a' lets the patch update non-text files; `-u'
3197 generates useful time stamps and enough context; and `-r' lets the
3198 patch update subdirectories.  Here is an example command, using Bourne
3199 shell syntax:
3200
3201      diff -Naur gcc-3.0.3 gcc-3.0.4
3202
3203    Tell your recipients how to apply the patches.  This should include
3204 which working directory to use, and which `patch' options to use; the
3205 option `-p1' is recommended.  Test your procedure by pretending to be a
3206 recipient and applying your patches to a copy of the original files.
3207
3208    *Note Avoiding Common Mistakes::, for how to avoid common mistakes
3209 when generating a patch.
3210
3211 \1f
3212 File: diff.info,  Node: Tips for Patch Consumers,  Next: Avoiding Common Mistakes,  Prev: Tips for Patch Producers,  Up: Making Patches
3213
3214 11.2 Tips for Patch Consumers
3215 =============================
3216
3217 A patch producer should tell recipients how to apply the patches, so
3218 the first rule of thumb for a patch consumer is to follow the
3219 instructions supplied with the patch.
3220
3221    GNU `diff' can analyze files with arbitrarily long lines and files
3222 that end in incomplete lines.  However, older versions of `patch'
3223 cannot patch such files.  If you are having trouble applying such
3224 patches, try upgrading to a recent version of GNU `patch'.
3225
3226 \1f
3227 File: diff.info,  Node: Avoiding Common Mistakes,  Next: Generating Smaller Patches,  Prev: Tips for Patch Consumers,  Up: Making Patches
3228
3229 11.3 Avoiding Common Mistakes
3230 =============================
3231
3232 When producing a patch for multiple files, apply `diff' to directories
3233 whose names do not have slashes.  This reduces confusion when the patch
3234 consumer specifies the `-pNUMBER' option, since this option can have
3235 surprising results when the old and new file names have different
3236 numbers of slashes.  For example, do not send a patch with a header
3237 that looks like this:
3238
3239      diff -Naur v2.0.29/prog/README prog/README
3240      --- v2.0.29/prog/README    2002-03-10 23:30:39.942229878 -0800
3241      +++ prog/README    2002-03-17 20:49:32.442260588 -0800
3242
3243 because the two file names have different numbers of slashes, and
3244 different versions of `patch' interpret the file names differently.  To
3245 avoid confusion, send output that looks like this instead:
3246
3247      diff -Naur v2.0.29/prog/README v2.0.30/prog/README
3248      --- v2.0.29/prog/README    2002-03-10 23:30:39.942229878 -0800
3249      +++ v2.0.30/prog/README    2002-03-17 20:49:32.442260588 -0800
3250
3251    Make sure you have specified the file names correctly, either in a
3252 context diff header or with an `Index:' line.  Take care to not send out
3253 reversed patches, since these make people wonder whether they have
3254 already applied the patch.
3255
3256    Avoid sending patches that compare backup file names like
3257 `README.orig' or `README~', since this might confuse `patch' into
3258 patching a backup file instead of the real file.  Instead, send patches
3259 that compare the same base file names in different directories, e.g.
3260 `old/README' and `new/README'.
3261
3262    To save people from partially applying a patch before other patches
3263 that should have gone before it, you can make the first patch in the
3264 patch file update a file with a name like `patchlevel.h' or
3265 `version.c', which contains a patch level or version number.  If the
3266 input file contains the wrong version number, `patch' will complain
3267 immediately.
3268
3269    An even clearer way to prevent this problem is to put a `Prereq:'
3270 line before the patch.  If the leading text in the patch file contains a
3271 line that starts with `Prereq:', `patch' takes the next word from that
3272 line (normally a version number) and checks whether the next input file
3273 contains that word, preceded and followed by either white space or a
3274 newline.  If not, `patch' prompts you for confirmation before
3275 proceeding.  This makes it difficult to accidentally apply patches in
3276 the wrong order.
3277
3278 \1f
3279 File: diff.info,  Node: Generating Smaller Patches,  Prev: Avoiding Common Mistakes,  Up: Making Patches
3280
3281 11.4 Generating Smaller Patches
3282 ===============================
3283
3284 The simplest way to generate a patch is to use `diff -Naur' (*note Tips
3285 for Patch Producers::), but you might be able to reduce the size of the
3286 patch by renaming or removing some files before making the patch.  If
3287 the older version of the package contains any files that the newer
3288 version does not, or if any files have been renamed between the two
3289 versions, make a list of `rm' and `mv' commands for the user to execute
3290 in the old version directory before applying the patch.  Then run those
3291 commands yourself in the scratch directory.
3292
3293    If there are any files that you don't need to include in the patch
3294 because they can easily be rebuilt from other files (for example,
3295 `TAGS' and output from `yacc' and `makeinfo'), exclude them from the
3296 patch by giving `diff' the `-x PATTERN' option (*note Comparing
3297 Directories::).  If you want your patch to modify a derived file
3298 because your recipients lack tools to build it, make sure that the
3299 patch for the derived file follows any patches for files that it
3300 depends on, so that the recipients' time stamps will not confuse `make'.
3301
3302    Now you can create the patch using `diff -Naur'.  Make sure to
3303 specify the scratch directory first and the newer directory second.
3304
3305    Add to the top of the patch a note telling the user any `rm' and
3306 `mv' commands to run before applying the patch.  Then you can remove
3307 the scratch directory.
3308
3309    You can also shrink the patch size by using fewer lines of context,
3310 but bear in mind that `patch' typically needs at least two lines for
3311 proper operation when patches do not exactly match the input files.
3312
3313 \1f
3314 File: diff.info,  Node: Invoking cmp,  Next: Invoking diff,  Prev: Making Patches,  Up: Top
3315
3316 12 Invoking `cmp'
3317 *****************
3318
3319 The `cmp' command compares two files, and if they differ, tells the
3320 first byte and line number where they differ or reports that one file
3321 is a prefix of the other.  Bytes and lines are numbered starting with
3322 1.  The arguments of `cmp' are as follows:
3323
3324      cmp OPTIONS... FROM-FILE [TO-FILE [FROM-SKIP [TO-SKIP]]]
3325
3326    The file name `-' is always the standard input.  `cmp' also uses the
3327 standard input if one file name is omitted.  The FROM-SKIP and TO-SKIP
3328 operands specify how many bytes to ignore at the start of each file;
3329 they are equivalent to the `--ignore-initial=FROM-SKIP:TO-SKIP' option.
3330
3331    By default, `cmp' outputs nothing if the two files have the same
3332 contents.  If one file is a prefix of the other, `cmp' prints to
3333 standard error a message of the following form:
3334
3335      cmp: EOF on SHORTER-FILE
3336
3337    Otherwise, `cmp' prints to standard output a message of the
3338 following form:
3339
3340      FROM-FILE TO-FILE differ: char BYTE-NUMBER, line LINE-NUMBER
3341
3342    The message formats can differ outside the POSIX locale.  Also,
3343 POSIX allows the EOF message to be followed by a blank and some
3344 additional information.
3345
3346    An exit status of 0 means no differences were found, 1 means some
3347 differences were found, and 2 means trouble.
3348
3349 * Menu:
3350
3351 * cmp Options:: Summary of options to `cmp'.
3352
3353 \1f
3354 File: diff.info,  Node: cmp Options,  Up: Invoking cmp
3355
3356 12.1 Options to `cmp'
3357 =====================
3358
3359 Below is a summary of all of the options that GNU `cmp' accepts.  Most
3360 options have two equivalent names, one of which is a single letter
3361 preceded by `-', and the other of which is a long name preceded by
3362 `--'.  Multiple single letter options (unless they take an argument)
3363 can be combined into a single command line word: `-bl' is equivalent to
3364 `-b -l'.
3365
3366 `-b'
3367 `--print-bytes'
3368      Print the differing bytes.  Display control bytes as a `^'
3369      followed by a letter of the alphabet and precede bytes that have
3370      the high bit set with `M-' (which stands for "meta").
3371
3372 `--help'
3373      Output a summary of usage and then exit.
3374
3375 `-i SKIP'
3376 `--ignore-initial=SKIP'
3377      Ignore any differences in the first SKIP bytes of the input files.
3378      Treat files with fewer than SKIP bytes as if they are empty.  If
3379      SKIP is of the form `FROM-SKIP:TO-SKIP', skip the first FROM-SKIP
3380      bytes of the first input file and the first TO-SKIP bytes of the
3381      second.
3382
3383 `-l'
3384 `--verbose'
3385      Output the (decimal) byte numbers and (octal) values of all
3386      differing bytes, instead of the default standard output.  Also,
3387      output the EOF message if one file is shorter than the other.
3388
3389 `-n COUNT'
3390 `--bytes=COUNT'
3391      Compare at most COUNT input bytes.
3392
3393 `-s'
3394 `--quiet'
3395 `--silent'
3396      Do not print anything; only return an exit status indicating
3397      whether the files differ.
3398
3399 `-v'
3400 `--version'
3401      Output version information and then exit.
3402
3403    In the above table, operands that are byte counts are normally
3404 decimal, but may be preceded by `0' for octal and `0x' for hexadecimal.
3405
3406    A byte count can be followed by a suffix to specify a multiple of
3407 that count; in this case an omitted integer is understood to be 1.  A
3408 bare size letter, or one followed by `iB', specifies a multiple using
3409 powers of 1024.  A size letter followed by `B' specifies powers of 1000
3410 instead.  For example, `-n 4M' and `-n 4MiB' are equivalent to `-n
3411 4194304', whereas `-n 4MB' is equivalent to `-n 4000000'.  This
3412 notation is upward compatible with the SI prefixes
3413 (http://www.bipm.fr/enus/3_SI/si-prefixes.html) for decimal multiples
3414 and with the IEC 60027-2 prefixes for binary multiples
3415 (http://physics.nist.gov/cuu/Units/binary.html).
3416
3417    The following suffixes are defined.  Large sizes like `1Y' may be
3418 rejected by your computer due to limitations of its arithmetic.
3419
3420 `kB'
3421      kilobyte: 10^3 = 1000.
3422
3423 `k'
3424 `K'
3425 `KiB'
3426      kibibyte: 2^10 = 1024.  `K' is special: the SI prefix is `k' and
3427      the IEC 60027-2 prefix is `Ki', but tradition and POSIX use `k' to
3428      mean `KiB'.
3429
3430 `MB'
3431      megabyte: 10^6 = 1,000,000.
3432
3433 `M'
3434 `MiB'
3435      mebibyte: 2^20 = 1,048,576.
3436
3437 `GB'
3438      gigabyte: 10^9 = 1,000,000,000.
3439
3440 `G'
3441 `GiB'
3442      gibibyte: 2^30 = 1,073,741,824.
3443
3444 `TB'
3445      terabyte:  10^12 = 1,000,000,000,000.
3446
3447 `T'
3448 `TiB'
3449      tebibyte: 2^40 = 1,099,511,627,776.
3450
3451 `PB'
3452      petabyte: 10^15 = 1,000,000,000,000,000.
3453
3454 `P'
3455 `PiB'
3456      pebibyte: 2^50 = 1,125,899,906,842,624.
3457
3458 `EB'
3459      exabyte: 10^18 = 1,000,000,000,000,000,000.
3460
3461 `E'
3462 `EiB'
3463      exbibyte: 2^60 = 1,152,921,504,606,846,976.
3464
3465 `ZB'
3466      zettabyte: 10^21 = 1,000,000,000,000,000,000,000
3467
3468 `Z'
3469 `ZiB'
3470      2^70 = 1,180,591,620,717,411,303,424.  (`Zi' is a GNU extension to
3471      IEC 60027-2.)
3472
3473 `YB'
3474      yottabyte: 10^24 = 1,000,000,000,000,000,000,000,000.
3475
3476 `Y'
3477 `YiB'
3478      2^80 = 1,208,925,819,614,629,174,706,176.  (`Yi' is a GNU
3479      extension to IEC 60027-2.)
3480
3481 \1f
3482 File: diff.info,  Node: Invoking diff,  Next: Invoking diff3,  Prev: Invoking cmp,  Up: Top
3483
3484 13 Invoking `diff'
3485 ******************
3486
3487 The format for running the `diff' command is:
3488
3489      diff OPTIONS... FILES...
3490
3491    In the simplest case, two file names FROM-FILE and TO-FILE are
3492 given, and `diff' compares the contents of FROM-FILE and TO-FILE.  A
3493 file name of `-' stands for text read from the standard input.  As a
3494 special case, `diff - -' compares a copy of standard input to itself.
3495
3496    If one file is a directory and the other is not, `diff' compares the
3497 file in the directory whose name is that of the non-directory.  The
3498 non-directory file must not be `-'.
3499
3500    If two file names are given and both are directories, `diff'
3501 compares corresponding files in both directories, in alphabetical
3502 order; this comparison is not recursive unless the `-r' or
3503 `--recursive' option is given.  `diff' never compares the actual
3504 contents of a directory as if it were a file.  The file that is fully
3505 specified may not be standard input, because standard input is nameless
3506 and the notion of "file with the same name" does not apply.
3507
3508    If the `--from-file=FILE' option is given, the number of file names
3509 is arbitrary, and FILE is compared to each named file.  Similarly, if
3510 the `--to-file=FILE' option is given, each named file is compared to
3511 FILE.
3512
3513    `diff' options begin with `-', so normally file names may not begin
3514 with `-'.  However, `--' as an argument by itself treats the remaining
3515 arguments as file names even if they begin with `-'.
3516
3517    An exit status of 0 means no differences were found, 1 means some
3518 differences were found, and 2 means trouble.  Normally, differing
3519 binary files count as trouble, but this can be altered by using the
3520 `-a' or `--text' option, or the `-q' or `--brief' option.
3521
3522 * Menu:
3523
3524 * diff Options:: Summary of options to `diff'.
3525
3526 \1f
3527 File: diff.info,  Node: diff Options,  Up: Invoking diff
3528
3529 13.1 Options to `diff'
3530 ======================
3531
3532 Below is a summary of all of the options that GNU `diff' accepts.  Most
3533 options have two equivalent names, one of which is a single letter
3534 preceded by `-', and the other of which is a long name preceded by
3535 `--'.  Multiple single letter options (unless they take an argument)
3536 can be combined into a single command line word: `-ac' is equivalent to
3537 `-a -c'.  Long named options can be abbreviated to any unique prefix of
3538 their name.  Brackets ([ and ]) indicate that an option takes an
3539 optional argument.
3540
3541 `-a'
3542 `--text'
3543      Treat all files as text and compare them line-by-line, even if they
3544      do not seem to be text.  *Note Binary::.
3545
3546 `-b'
3547 `--ignore-space-change'
3548      Ignore changes in amount of white space.  *Note White Space::.
3549
3550 `-B'
3551 `--ignore-blank-lines'
3552      Ignore changes that just insert or delete blank lines.  *Note
3553      Blank Lines::.
3554
3555 `--binary'
3556      Read and write data in binary mode.  *Note Binary::.
3557
3558 `-c'
3559      Use the context output format, showing three lines of context.
3560      *Note Context Format::.
3561
3562 `-C LINES'
3563 `--context[=LINES]'
3564      Use the context output format, showing LINES (an integer) lines of
3565      context, or three if LINES is not given.  *Note Context Format::.
3566      For proper operation, `patch' typically needs at least two lines of
3567      context.
3568
3569      For compatibility `diff' also supports an obsolete option syntax
3570      `-LINES' that has effect when combined with `-c', `-p', or `-u'.
3571      New scripts should use `-C LINES' or `-U LINES' instead.
3572
3573 `--changed-group-format=FORMAT'
3574      Use FORMAT to output a line group containing differing lines from
3575      both files in if-then-else format.  *Note Line Group Formats::.
3576
3577 `-d'
3578 `--minimal'
3579      Change the algorithm perhaps find a smaller set of changes.  This
3580      makes `diff' slower (sometimes much slower).  *Note diff
3581      Performance::.
3582
3583 `-D NAME'
3584 `--ifdef=NAME'
3585      Make merged `#ifdef' format output, conditional on the preprocessor
3586      macro NAME.  *Note If-then-else::.
3587
3588 `-e'
3589 `--ed'
3590      Make output that is a valid `ed' script.  *Note ed Scripts::.
3591
3592 `-E'
3593 `--ignore-tab-expansion'
3594      Ignore changes due to tab expansion.  *Note White Space::.
3595
3596 `-f'
3597 `--forward-ed'
3598      Make output that looks vaguely like an `ed' script but has changes
3599      in the order they appear in the file.  *Note Forward ed::.
3600
3601 `-F REGEXP'
3602 `--show-function-line=REGEXP'
3603      In context and unified format, for each hunk of differences, show
3604      some of the last preceding line that matches REGEXP.  *Note
3605      Specified Headings::.
3606
3607 `--from-file=FILE'
3608      Compare FILE to each operand; FILE may be a directory.
3609
3610 `--help'
3611      Output a summary of usage and then exit.
3612
3613 `--horizon-lines=LINES'
3614      Do not discard the last LINES lines of the common prefix and the
3615      first LINES lines of the common suffix.  *Note diff Performance::.
3616
3617 `-i'
3618 `--ignore-case'
3619      Ignore changes in case; consider upper- and lower-case letters
3620      equivalent.  *Note Case Folding::.
3621
3622 `-I REGEXP'
3623 `--ignore-matching-lines=REGEXP'
3624      Ignore changes that just insert or delete lines that match REGEXP.
3625      *Note Specified Lines::.
3626
3627 `--ignore-file-name-case'
3628      Ignore case when comparing file names during recursive comparison.
3629      *Note Comparing Directories::.
3630
3631 `-l'
3632 `--paginate'
3633      Pass the output through `pr' to paginate it.  *Note Pagination::.
3634
3635 `--label=LABEL'
3636      Use LABEL instead of the file name in the context format (*note
3637      Context Format::) and unified format (*note Unified Format::)
3638      headers.  *Note RCS::.
3639
3640 `--left-column'
3641      Print only the left column of two common lines in side by side
3642      format.  *Note Side by Side Format::.
3643
3644 `--line-format=FORMAT'
3645      Use FORMAT to output all input lines in if-then-else format.
3646      *Note Line Formats::.
3647
3648 `-n'
3649 `--rcs'
3650      Output RCS-format diffs; like `-f' except that each command
3651      specifies the number of lines affected.  *Note RCS::.
3652
3653 `-N'
3654 `--new-file'
3655      In directory comparison, if a file is found in only one directory,
3656      treat it as present but empty in the other directory.  *Note
3657      Comparing Directories::.
3658
3659 `--new-group-format=FORMAT'
3660      Use FORMAT to output a group of lines taken from just the second
3661      file in if-then-else format.  *Note Line Group Formats::.
3662
3663 `--new-line-format=FORMAT'
3664      Use FORMAT to output a line taken from just the second file in
3665      if-then-else format.  *Note Line Formats::.
3666
3667 `--old-group-format=FORMAT'
3668      Use FORMAT to output a group of lines taken from just the first
3669      file in if-then-else format.  *Note Line Group Formats::.
3670
3671 `--old-line-format=FORMAT'
3672      Use FORMAT to output a line taken from just the first file in
3673      if-then-else format.  *Note Line Formats::.
3674
3675 `-p'
3676 `--show-c-function'
3677      Show which C function each change is in.  *Note C Function
3678      Headings::.
3679
3680 `-q'
3681 `--brief'
3682      Report only whether the files differ, not the details of the
3683      differences.  *Note Brief::.
3684
3685 `-r'
3686 `--recursive'
3687      When comparing directories, recursively compare any subdirectories
3688      found.  *Note Comparing Directories::.
3689
3690 `-s'
3691 `--report-identical-files'
3692      Report when two files are the same.  *Note Comparing Directories::.
3693
3694 `-S FILE'
3695 `--starting-file=FILE'
3696      When comparing directories, start with the file FILE.  This is
3697      used for resuming an aborted comparison.  *Note Comparing
3698      Directories::.
3699
3700 `--speed-large-files'
3701      Use heuristics to speed handling of large files that have numerous
3702      scattered small changes.  *Note diff Performance::.
3703
3704 `--strip-trailing-cr'
3705      Strip any trailing carriage return at the end of an input line.
3706      *Note Binary::.
3707
3708 `--suppress-common-lines'
3709      Do not print common lines in side by side format.  *Note Side by
3710      Side Format::.
3711
3712 `-t'
3713 `--expand-tabs'
3714      Expand tabs to spaces in the output, to preserve the alignment of
3715      tabs in the input files.  *Note Tabs::.
3716
3717 `-T'
3718 `--initial-tab'
3719      Output a tab rather than a space before the text of a line in
3720      normal or context format.  This causes the alignment of tabs in
3721      the line to look normal.  *Note Tabs::.
3722
3723 `--tabsize=COLUMNS'
3724      Assume that tab stops are set every COLUMNS (default 8) print
3725      columns.  *Note Tabs::.
3726
3727 `--suppress-blank-empty'
3728      Suppress any blanks before newlines when printing the
3729      representation of an empty line, when outputting normal, context,
3730      or unified format.  *Note Trailing Blanks::.
3731
3732 `--to-file=FILE'
3733      Compare each operand to FILE; FILE may be a directory.
3734
3735 `-u'
3736      Use the unified output format, showing three lines of context.
3737      *Note Unified Format::.
3738
3739 `--unchanged-group-format=FORMAT'
3740      Use FORMAT to output a group of common lines taken from both files
3741      in if-then-else format.  *Note Line Group Formats::.
3742
3743 `--unchanged-line-format=FORMAT'
3744      Use FORMAT to output a line common to both files in if-then-else
3745      format.  *Note Line Formats::.
3746
3747 `--unidirectional-new-file'
3748      When comparing directories, if a file appears only in the second
3749      directory of the two, treat it as present but empty in the other.
3750      *Note Comparing Directories::.
3751
3752 `-U LINES'
3753 `--unified[=LINES]'
3754      Use the unified output format, showing LINES (an integer) lines of
3755      context, or three if LINES is not given.  *Note Unified Format::.
3756      For proper operation, `patch' typically needs at least two lines of
3757      context.
3758
3759      On older systems, `diff' supports an obsolete option `-LINES' that
3760      has effect when combined with `-u'.  POSIX 1003.1-2001 (*note
3761      Standards conformance::) does not allow this; use `-U LINES'
3762      instead.
3763
3764 `-v'
3765 `--version'
3766      Output version information and then exit.
3767
3768 `-w'
3769 `--ignore-all-space'
3770      Ignore white space when comparing lines.  *Note White Space::.
3771
3772 `-W COLUMNS'
3773 `--width=COLUMNS'
3774      Output at most COLUMNS (default 130) print columns per line in
3775      side by side format.  *Note Side by Side Format::.
3776
3777 `-x PATTERN'
3778 `--exclude=PATTERN'
3779      When comparing directories, ignore files and subdirectories whose
3780      basenames match PATTERN.  *Note Comparing Directories::.
3781
3782 `-X FILE'
3783 `--exclude-from=FILE'
3784      When comparing directories, ignore files and subdirectories whose
3785      basenames match any pattern contained in FILE.  *Note Comparing
3786      Directories::.
3787
3788 `-y'
3789 `--side-by-side'
3790      Use the side by side output format.  *Note Side by Side Format::.
3791
3792 \1f
3793 File: diff.info,  Node: Invoking diff3,  Next: Invoking patch,  Prev: Invoking diff,  Up: Top
3794
3795 14 Invoking `diff3'
3796 *******************
3797
3798 The `diff3' command compares three files and outputs descriptions of
3799 their differences.  Its arguments are as follows:
3800
3801      diff3 OPTIONS... MINE OLDER YOURS
3802
3803    The files to compare are MINE, OLDER, and YOURS.  At most one of
3804 these three file names may be `-', which tells `diff3' to read the
3805 standard input for that file.
3806
3807    An exit status of 0 means `diff3' was successful, 1 means some
3808 conflicts were found, and 2 means trouble.
3809
3810 * Menu:
3811
3812 * diff3 Options:: Summary of options to `diff3'.
3813
3814 \1f
3815 File: diff.info,  Node: diff3 Options,  Up: Invoking diff3
3816
3817 14.1 Options to `diff3'
3818 =======================
3819
3820 Below is a summary of all of the options that GNU `diff3' accepts.
3821 Multiple single letter options (unless they take an argument) can be
3822 combined into a single command line argument.
3823
3824 `-a'
3825 `--text'
3826      Treat all files as text and compare them line-by-line, even if they
3827      do not appear to be text.  *Note Binary::.
3828
3829 `-A'
3830 `--show-all'
3831      Incorporate all unmerged changes from OLDER to YOURS into MINE,
3832      surrounding conflicts with bracket lines.  *Note Marking
3833      Conflicts::.
3834
3835 `--diff-program=PROGRAM'
3836      Use the compatible comparison program PROGRAM to compare files
3837      instead of `diff'.
3838
3839 `-e'
3840 `--ed'
3841      Generate an `ed' script that incorporates all the changes from
3842      OLDER to YOURS into MINE.  *Note Which Changes::.
3843
3844 `-E'
3845 `--show-overlap'
3846      Like `-e', except bracket lines from overlapping changes' first
3847      and third files.  *Note Marking Conflicts::.  With `-E', an
3848      overlapping change looks like this:
3849
3850           <<<<<<< MINE
3851           lines from MINE
3852           =======
3853           lines from YOURS
3854           >>>>>>> YOURS
3855
3856 `--help'
3857      Output a summary of usage and then exit.
3858
3859 `-i'
3860      Generate `w' and `q' commands at the end of the `ed' script for
3861      System V compatibility.  This option must be combined with one of
3862      the `-AeExX3' options, and may not be combined with `-m'.  *Note
3863      Saving the Changed File::.
3864
3865 `--label=LABEL'
3866      Use the label LABEL for the brackets output by the `-A', `-E' and
3867      `-X' options.  This option may be given up to three times, one for
3868      each input file.  The default labels are the names of the input
3869      files.  Thus `diff3 --label X --label Y --label Z -m A B C' acts
3870      like `diff3 -m A B C', except that the output looks like it came
3871      from files named `X', `Y' and `Z' rather than from files named
3872      `A', `B' and `C'.  *Note Marking Conflicts::.
3873
3874 `-m'
3875 `--merge'
3876      Apply the edit script to the first file and send the result to
3877      standard output.  Unlike piping the output from `diff3' to `ed',
3878      this works even for binary files and incomplete lines.  `-A' is
3879      assumed if no edit script option is specified.  *Note Bypassing
3880      ed::.
3881
3882 `--strip-trailing-cr'
3883      Strip any trailing carriage return at the end of an input line.
3884      *Note Binary::.
3885
3886 `-T'
3887 `--initial-tab'
3888      Output a tab rather than two spaces before the text of a line in
3889      normal format.  This causes the alignment of tabs in the line to
3890      look normal.  *Note Tabs::.
3891
3892 `-v'
3893 `--version'
3894      Output version information and then exit.
3895
3896 `-x'
3897 `--overlap-only'
3898      Like `-e', except output only the overlapping changes.  *Note
3899      Which Changes::.
3900
3901 `-X'
3902      Like `-E', except output only the overlapping changes.  In other
3903      words, like `-x', except bracket changes as in `-E'.  *Note
3904      Marking Conflicts::.
3905
3906 `-3'
3907 `--easy-only'
3908      Like `-e', except output only the nonoverlapping changes.  *Note
3909      Which Changes::.
3910
3911 \1f
3912 File: diff.info,  Node: Invoking patch,  Next: Invoking sdiff,  Prev: Invoking diff3,  Up: Top
3913
3914 15 Invoking `patch'
3915 *******************
3916
3917 Normally `patch' is invoked like this:
3918
3919      patch <PATCHFILE
3920
3921    The full format for invoking `patch' is:
3922
3923      patch OPTIONS... [ORIGFILE [PATCHFILE]]
3924
3925    You can also specify where to read the patch from with the `-i
3926 PATCHFILE' or `--input=PATCHFILE' option.  If you do not specify
3927 PATCHFILE, or if PATCHFILE is `-', `patch' reads the patch (that is,
3928 the `diff' output) from the standard input.
3929
3930    If you do not specify an input file on the command line, `patch'
3931 tries to intuit from the "leading text" (any text in the patch that
3932 comes before the `diff' output) which file to edit.  *Note Multiple
3933 Patches::.
3934
3935    By default, `patch' replaces the original input file with the
3936 patched version, possibly after renaming the original file into a
3937 backup file (*note Backup Names::, for a description of how `patch'
3938 names backup files).  You can also specify where to put the output with
3939 the `-o FILE' or `--output=FILE' option; however, do not use this option
3940 if FILE is one of the input files.
3941
3942 * Menu:
3943
3944 * patch Options::     Summary table of options to `patch'.
3945
3946 \1f
3947 File: diff.info,  Node: patch Options,  Up: Invoking patch
3948
3949 15.1 Options to `patch'
3950 =======================
3951
3952 Here is a summary of all of the options that GNU `patch' accepts.
3953 *Note patch and Tradition::, for which of these options are safe to use
3954 in older versions of `patch'.
3955
3956    Multiple single-letter options that do not take an argument can be
3957 combined into a single command line argument with only one dash.
3958
3959 `-b'
3960 `--backup'
3961      Back up the original contents of each file, even if backups would
3962      normally not be made.  *Note Backups::.
3963
3964 `-B PREFIX'
3965 `--prefix=PREFIX'
3966      Prepend PREFIX to backup file names.  *Note Backup Names::.
3967
3968 `--backup-if-mismatch'
3969      Back up the original contents of each file if the patch does not
3970      exactly match the file.  This is the default behavior when not
3971      conforming to POSIX.  *Note Backups::.
3972
3973 `--binary'
3974      Read and write all files in binary mode, except for standard output
3975      and `/dev/tty'.  This option has no effect on POSIX-conforming
3976      systems like GNU/Linux.  On systems where this option makes a
3977      difference, the patch should be generated by `diff -a --binary'.
3978      *Note Binary::.
3979
3980 `-c'
3981 `--context'
3982      Interpret the patch file as a context diff.  *Note patch Input::.
3983
3984 `-d DIRECTORY'
3985 `--directory=DIRECTORY'
3986      Make directory DIRECTORY the current directory for interpreting
3987      both file names in the patch file, and file names given as
3988      arguments to other options.  *Note patch Directories::.
3989
3990 `-D NAME'
3991 `--ifdef=NAME'
3992      Make merged if-then-else output using NAME.  *Note If-then-else::.
3993
3994 `--dry-run'
3995      Print the results of applying the patches without actually changing
3996      any files.  *Note Dry Runs::.
3997
3998 `-e'
3999 `--ed'
4000      Interpret the patch file as an `ed' script.  *Note patch Input::.
4001
4002 `-E'
4003 `--remove-empty-files'
4004      Remove output files that are empty after the patches have been
4005      applied.  *Note Creating and Removing::.
4006
4007 `-f'
4008 `--force'
4009      Assume that the user knows exactly what he or she is doing, and do
4010      not ask any questions.  *Note patch Messages::.
4011
4012 `-F LINES'
4013 `--fuzz=LINES'
4014      Set the maximum fuzz factor to LINES.  *Note Inexact::.
4015
4016 `-g NUM'
4017 `--get=NUM'
4018      If NUM is positive, get input files from a revision control system
4019      as necessary; if zero, do not get the files; if negative, ask the
4020      user whether to get the files.  *Note Revision Control::.
4021
4022 `--help'
4023      Output a summary of usage and then exit.
4024
4025 `-i PATCHFILE'
4026 `--input=PATCHFILE'
4027      Read the patch from PATCHFILE rather than from standard input.
4028      *Note patch Options::.
4029
4030 `-l'
4031 `--ignore-white-space'
4032      Let any sequence of blanks (spaces or tabs) in the patch file match
4033      any sequence of blanks in the input file.  *Note Changed White
4034      Space::.
4035
4036 `-n'
4037 `--normal'
4038      Interpret the patch file as a normal diff.  *Note patch Input::.
4039
4040 `-N'
4041 `--forward'
4042      Ignore patches that `patch' thinks are reversed or already applied.
4043      See also `-R'.  *Note Reversed Patches::.
4044
4045 `--no-backup-if-mismatch'
4046      Do not back up the original contents of files.  This is the default
4047      behavior when conforming to POSIX.  *Note Backups::.
4048
4049 `-o FILE'
4050 `--output=FILE'
4051      Use FILE as the output file name.  *Note patch Options::.
4052
4053 `-pNUMBER'
4054 `--strip=NUMBER'
4055      Set the file name strip count to NUMBER.  *Note patch
4056      Directories::.
4057
4058 `--posix'
4059      Conform to POSIX, as if the `POSIXLY_CORRECT' environment variable
4060      had been set.  *Note patch and POSIX::.
4061
4062 `--quoting-style=WORD'
4063      Use style WORD to quote names in diagnostics, as if the
4064      `QUOTING_STYLE' environment variable had been set to WORD.  *Note
4065      patch Quoting Style::.
4066
4067 `-r REJECT-FILE'
4068 `--reject-file=REJECT-FILE'
4069      Use REJECT-FILE as the reject file name.  *Note Reject Names::.
4070
4071 `-R'
4072 `--reverse'
4073      Assume that this patch was created with the old and new files
4074      swapped.  *Note Reversed Patches::.
4075
4076 `-s'
4077 `--quiet'
4078 `--silent'
4079      Work silently unless an error occurs.  *Note patch Messages::.
4080
4081 `-t'
4082 `--batch'
4083      Do not ask any questions.  *Note patch Messages::.
4084
4085 `-T'
4086 `--set-time'
4087      Set the modification and access times of patched files from time
4088      stamps given in context diff headers, assuming that the context
4089      diff headers use local time.  *Note Patching Time Stamps::.
4090
4091 `-u'
4092 `--unified'
4093      Interpret the patch file as a unified diff.  *Note patch Input::.
4094
4095 `-v'
4096 `--version'
4097      Output version information and then exit.
4098
4099 `-V BACKUP-STYLE'
4100 `--version=control=BACKUP-STYLE'
4101      Select the naming convention for backup file names.  *Note Backup
4102      Names::.
4103
4104 `--verbose'
4105      Print more diagnostics than usual.  *Note patch Messages::.
4106
4107 `-x NUMBER'
4108 `--debug=NUMBER'
4109      Set internal debugging flags.  Of interest only to `patch'
4110      patchers.
4111
4112 `-Y PREFIX'
4113 `--basename-prefix=PREFIX'
4114      Prepend PREFIX to base names of backup files.  *Note Backup
4115      Names::.
4116
4117 `-z SUFFIX'
4118 `--suffix=SUFFIX'
4119      Use SUFFIX as the backup extension instead of `.orig' or `~'.
4120      *Note Backup Names::.
4121
4122 `-Z'
4123 `--set-utc'
4124      Set the modification and access times of patched files from time
4125      stamps given in context diff headers, assuming that the context
4126      diff headers use UTC.  *Note Patching Time Stamps::.
4127
4128
4129 \1f
4130 File: diff.info,  Node: Invoking sdiff,  Next: Standards conformance,  Prev: Invoking patch,  Up: Top
4131
4132 16 Invoking `sdiff'
4133 *******************
4134
4135 The `sdiff' command merges two files and interactively outputs the
4136 results.  Its arguments are as follows:
4137
4138      sdiff -o OUTFILE OPTIONS... FROM-FILE TO-FILE
4139
4140    This merges FROM-FILE with TO-FILE, with output to OUTFILE.  If
4141 FROM-FILE is a directory and TO-FILE is not, `sdiff' compares the file
4142 in FROM-FILE whose file name is that of TO-FILE, and vice versa.
4143 FROM-FILE and TO-FILE may not both be directories.
4144
4145    `sdiff' options begin with `-', so normally FROM-FILE and TO-FILE
4146 may not begin with `-'.  However, `--' as an argument by itself treats
4147 the remaining arguments as file names even if they begin with `-'.  You
4148 may not use `-' as an input file.
4149
4150    `sdiff' without `-o' (or `--output') produces a side-by-side
4151 difference.  This usage is obsolete; use the `-y' or `--side-by-side'
4152 option of `diff' instead.
4153
4154    An exit status of 0 means no differences were found, 1 means some
4155 differences were found, and 2 means trouble.
4156
4157 * Menu:
4158
4159 * sdiff Options:: Summary of options to `diff'.
4160
4161 \1f
4162 File: diff.info,  Node: sdiff Options,  Up: Invoking sdiff
4163
4164 16.1 Options to `sdiff'
4165 =======================
4166
4167 Below is a summary of all of the options that GNU `sdiff' accepts.
4168 Each option has two equivalent names, one of which is a single letter
4169 preceded by `-', and the other of which is a long name preceded by
4170 `--'.  Multiple single letter options (unless they take an argument)
4171 can be combined into a single command line argument.  Long named
4172 options can be abbreviated to any unique prefix of their name.
4173
4174 `-a'
4175 `--text'
4176      Treat all files as text and compare them line-by-line, even if they
4177      do not appear to be text.  *Note Binary::.
4178
4179 `-b'
4180 `--ignore-space-change'
4181      Ignore changes in amount of white space.  *Note White Space::.
4182
4183 `-B'
4184 `--ignore-blank-lines'
4185      Ignore changes that just insert or delete blank lines.  *Note
4186      Blank Lines::.
4187
4188 `-d'
4189 `--minimal'
4190      Change the algorithm to perhaps find a smaller set of changes.
4191      This makes `sdiff' slower (sometimes much slower).  *Note diff
4192      Performance::.
4193
4194 `--diff-program=PROGRAM'
4195      Use the compatible comparison program PROGRAM to compare files
4196      instead of `diff'.
4197
4198 `-E'
4199 `--ignore-tab-expansion'
4200      Ignore changes due to tab expansion.  *Note White Space::.
4201
4202 `--help'
4203      Output a summary of usage and then exit.
4204
4205 `-i'
4206 `--ignore-case'
4207      Ignore changes in case; consider upper- and lower-case to be the
4208      same.  *Note Case Folding::.
4209
4210 `-I REGEXP'
4211 `--ignore-matching-lines=REGEXP'
4212      Ignore changes that just insert or delete lines that match REGEXP.
4213      *Note Specified Lines::.
4214
4215 `-l'
4216 `--left-column'
4217      Print only the left column of two common lines.  *Note Side by
4218      Side Format::.
4219
4220 `-o FILE'
4221 `--output=FILE'
4222      Put merged output into FILE.  This option is required for merging.
4223
4224 `-s'
4225 `--suppress-common-lines'
4226      Do not print common lines.  *Note Side by Side Format::.
4227
4228 `--speed-large-files'
4229      Use heuristics to speed handling of large files that have numerous
4230      scattered small changes.  *Note diff Performance::.
4231
4232 `--strip-trailing-cr'
4233      Strip any trailing carriage return at the end of an input line.
4234      *Note Binary::.
4235
4236 `-t'
4237 `--expand-tabs'
4238      Expand tabs to spaces in the output, to preserve the alignment of
4239      tabs in the input files.  *Note Tabs::.
4240
4241 `--tabsize=COLUMNS'
4242      Assume that tab stops are set every COLUMNS (default 8) print
4243      columns.  *Note Tabs::.
4244
4245 `-v'
4246 `--version'
4247      Output version information and then exit.
4248
4249 `-w COLUMNS'
4250 `--width=COLUMNS'
4251      Output at most COLUMNS (default 130) print columns per line.
4252      *Note Side by Side Format::.  Note that for historical reasons,
4253      this option is `-W' in `diff', `-w' in `sdiff'.
4254
4255 `-W'
4256 `--ignore-all-space'
4257      Ignore white space when comparing lines.  *Note White Space::.
4258      Note that for historical reasons, this option is `-w' in `diff',
4259      `-W' in `sdiff'.
4260
4261 \1f
4262 File: diff.info,  Node: Standards conformance,  Next: Projects,  Prev: Invoking sdiff,  Up: Top
4263
4264 17 Standards conformance
4265 ************************
4266
4267 In a few cases, the GNU utilities' default behavior is incompatible
4268 with the POSIX standard.  To suppress these incompatibilities, define
4269 the `POSIXLY_CORRECT' environment variable.  Unless you are checking
4270 for POSIX conformance, you probably do not need to define
4271 `POSIXLY_CORRECT'.
4272
4273    Normally options and operands can appear in any order, and programs
4274 act as if all the options appear before any operands.  For example,
4275 `diff lao tzu -C 2' acts like `diff -C 2 lao tzu', since `2' is an
4276 option-argument of `-C'.  However, if the `POSIXLY_CORRECT' environment
4277 variable is set, options must appear before operands, unless otherwise
4278 specified for a particular command.
4279
4280    Newer versions of POSIX are occasionally incompatible with older
4281 versions.  For example, older versions of POSIX allowed the command
4282 `diff -c -10' to have the same meaning as `diff -C 10', but POSIX
4283 1003.1-2001 `diff' no longer allows digit-string options like `-10'.
4284
4285    The GNU utilities normally conform to the version of POSIX that is
4286 standard for your system.  To cause them to conform to a different
4287 version of POSIX, define the `_POSIX2_VERSION' environment variable to
4288 a value of the form YYYYMM specifying the year and month the standard
4289 was adopted.  Two values are currently supported for `_POSIX2_VERSION':
4290 `199209' stands for POSIX 1003.2-1992, and `200112' stands for POSIX
4291 1003.1-2001.  For example, if you are running older software that
4292 assumes an older version of POSIX and uses `diff -c -10', you can work
4293 around the compatibility problems by setting `_POSIX2_VERSION=199209'
4294 in your environment.
4295
4296 \1f
4297 File: diff.info,  Node: Projects,  Next: Copying This Manual,  Prev: Standards conformance,  Up: Top
4298
4299 18 Future Projects
4300 ******************
4301
4302 Here are some ideas for improving GNU `diff' and `patch'.  The GNU
4303 project has identified some improvements as potential programming
4304 projects for volunteers.  You can also help by reporting any bugs that
4305 you find.
4306
4307    If you are a programmer and would like to contribute something to the
4308 GNU project, please consider volunteering for one of these projects.
4309 If you are seriously contemplating work, please write to <gvc@gnu.org>
4310 to coordinate with other volunteers.
4311
4312 * Menu:
4313
4314 * Shortcomings:: Suggested projects for improvements.
4315 * Bugs::         Reporting bugs.
4316
4317 \1f
4318 File: diff.info,  Node: Shortcomings,  Next: Bugs,  Up: Projects
4319
4320 18.1 Suggested Projects for Improving GNU `diff' and `patch'
4321 ============================================================
4322
4323 One should be able to use GNU `diff' to generate a patch from any pair
4324 of directory trees, and given the patch and a copy of one such tree,
4325 use `patch' to generate a faithful copy of the other.  Unfortunately,
4326 some changes to directory trees cannot be expressed using current patch
4327 formats; also, `patch' does not handle some of the existing formats.
4328 These shortcomings motivate the following suggested projects.
4329
4330 * Menu:
4331
4332 * Internationalization:: Handling multibyte and varying-width characters.
4333 * Changing Structure::   Handling changes to the directory structure.
4334 * Special Files::        Handling symbolic links, device special files, etc.
4335 * Unusual File Names::   Handling file names that contain unusual characters.
4336 * Time Stamp Order::     Outputting diffs in time stamp order.
4337 * Ignoring Changes::     Ignoring certain changes while showing others.
4338 * Speedups::             Improving performance.
4339
4340 \1f
4341 File: diff.info,  Node: Internationalization,  Next: Changing Structure,  Up: Shortcomings
4342
4343 18.1.1 Handling Multibyte and Varying-Width Characters
4344 ------------------------------------------------------
4345
4346 `diff', `diff3' and `sdiff' treat each line of input as a string of
4347 unibyte characters.  This can mishandle multibyte characters in some
4348 cases.  For example, when asked to ignore spaces, `diff' does not
4349 properly ignore a multibyte space character.
4350
4351    Also, `diff' currently assumes that each byte is one column wide,
4352 and this assumption is incorrect in some locales, e.g., locales that
4353 use UTF-8 encoding.  This causes problems with the `-y' or
4354 `--side-by-side' option of `diff'.
4355
4356    These problems need to be fixed without unduly affecting the
4357 performance of the utilities in unibyte environments.
4358
4359    The IBM GNU/Linux Technology Center Internationalization Team has
4360 proposed patches to support internationalized `diff'
4361 (http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz).
4362 Unfortunately, these patches are incomplete and are to an older version
4363 of `diff', so more work needs to be done in this area.
4364
4365 \1f
4366 File: diff.info,  Node: Changing Structure,  Next: Special Files,  Prev: Internationalization,  Up: Shortcomings
4367
4368 18.1.2 Handling Changes to the Directory Structure
4369 --------------------------------------------------
4370
4371 `diff' and `patch' do not handle some changes to directory structure.
4372 For example, suppose one directory tree contains a directory named `D'
4373 with some subsidiary files, and another contains a file with the same
4374 name `D'.  `diff -r' does not output enough information for `patch' to
4375 transform the directory subtree into the file.
4376
4377    There should be a way to specify that a file has been removed without
4378 having to include its entire contents in the patch file.  There should
4379 also be a way to tell `patch' that a file was renamed, even if there is
4380 no way for `diff' to generate such information.  There should be a way
4381 to tell `patch' that a file's time stamp has changed, even if its
4382 contents have not changed.
4383
4384    These problems can be fixed by extending the `diff' output format to
4385 represent changes in directory structure, and extending `patch' to
4386 understand these extensions.
4387
4388 \1f
4389 File: diff.info,  Node: Special Files,  Next: Unusual File Names,  Prev: Changing Structure,  Up: Shortcomings
4390
4391 18.1.3 Files that are Neither Directories Nor Regular Files
4392 -----------------------------------------------------------
4393
4394 Some files are neither directories nor regular files: they are unusual
4395 files like symbolic links, device special files, named pipes, and
4396 sockets.  Currently, `diff' treats symbolic links as if they were the
4397 pointed-to files, except that a recursive `diff' reports an error if it
4398 detects infinite loops of symbolic links (e.g., symbolic links to
4399 `..').  `diff' treats other special files like regular files if they
4400 are specified at the top level, but simply reports their presence when
4401 comparing directories.  This means that `patch' cannot represent
4402 changes to such files.  For example, if you change which file a
4403 symbolic link points to, `diff' outputs the difference between the two
4404 files, instead of the change to the symbolic link.
4405
4406    `diff' should optionally report changes to special files specially,
4407 and `patch' should be extended to understand these extensions.
4408
4409 \1f
4410 File: diff.info,  Node: Unusual File Names,  Next: Time Stamp Order,  Prev: Special Files,  Up: Shortcomings
4411
4412 18.1.4 File Names that Contain Unusual Characters
4413 -------------------------------------------------
4414
4415 When a file name contains an unusual character like a newline or white
4416 space, `diff -r' generates a patch that `patch' cannot parse.  The
4417 problem is with format of `diff' output, not just with `patch', because
4418 with odd enough file names one can cause `diff' to generate a patch
4419 that is syntactically correct but patches the wrong files.  The format
4420 of `diff' output should be extended to handle all possible file names.
4421
4422 \1f
4423 File: diff.info,  Node: Time Stamp Order,  Next: Ignoring Changes,  Prev: Unusual File Names,  Up: Shortcomings
4424
4425 18.1.5 Outputting Diffs in Time Stamp Order
4426 -------------------------------------------
4427
4428 Applying `patch' to a multiple-file diff can result in files whose time
4429 stamps are out of order.  GNU `patch' has options to restore the time
4430 stamps of the updated files (*note Patching Time Stamps::), but
4431 sometimes it is useful to generate a patch that works even if the
4432 recipient does not have GNU patch, or does not use these options.  One
4433 way to do this would be to implement a `diff' option to output diffs in
4434 time stamp order.
4435
4436 \1f
4437 File: diff.info,  Node: Ignoring Changes,  Next: Speedups,  Prev: Time Stamp Order,  Up: Shortcomings
4438
4439 18.1.6 Ignoring Certain Changes
4440 -------------------------------
4441
4442 It would be nice to have a feature for specifying two strings, one in
4443 FROM-FILE and one in TO-FILE, which should be considered to match.
4444 Thus, if the two strings are `foo' and `bar', then if two lines differ
4445 only in that `foo' in file 1 corresponds to `bar' in file 2, the lines
4446 are treated as identical.
4447
4448    It is not clear how general this feature can or should be, or what
4449 syntax should be used for it.
4450
4451    A partial substitute is to filter one or both files before comparing,
4452 e.g.:
4453
4454      sed 's/foo/bar/g' file1 | diff - file2
4455
4456    However, this outputs the filtered text, not the original.
4457
4458 \1f
4459 File: diff.info,  Node: Speedups,  Prev: Ignoring Changes,  Up: Shortcomings
4460
4461 18.1.7 Improving Performance
4462 ----------------------------
4463
4464 When comparing two large directory structures, one of which was
4465 originally copied from the other with time stamps preserved (e.g., with
4466 `cp -pR'), it would greatly improve performance if an option told
4467 `diff' to assume that two files with the same size and time stamps have
4468 the same content.  *Note diff Performance::.
4469
4470 \1f
4471 File: diff.info,  Node: Bugs,  Prev: Shortcomings,  Up: Projects
4472
4473 18.2 Reporting Bugs
4474 ===================
4475
4476 If you think you have found a bug in GNU `cmp', `diff', `diff3', or
4477 `sdiff', please report it by electronic mail to the GNU utilities bug
4478 report mailing list
4479 (http://mail.gnu.org/mailman/listinfo/bug-gnu-utils)
4480 <bug-gnu-utils@gnu.org>.  Please send bug reports for GNU `patch' to
4481 <bug-patch@gnu.org>.  Send as precise a description of the problem as
4482 you can, including the output of the `--version' option and sample
4483 input files that produce the bug, if applicable.  If you have a
4484 nontrivial fix for the bug, please send it as well.  If you have a
4485 patch, please send it too.  It may simplify the maintainer's job if the
4486 patch is relative to a recent test release, which you can find in the
4487 directory `ftp://alpha.gnu.org/gnu/diffutils/'.
4488
4489 \1f
4490 File: diff.info,  Node: Copying This Manual,  Next: Translations,  Prev: Projects,  Up: Top
4491
4492 Appendix A Copying This Manual
4493 ******************************
4494
4495                      Version 1.3, 3 November 2008
4496
4497      Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
4498      `http://fsf.org/'
4499
4500      Everyone is permitted to copy and distribute verbatim copies
4501      of this license document, but changing it is not allowed.
4502
4503   0. PREAMBLE
4504
4505      The purpose of this License is to make a manual, textbook, or other
4506      functional and useful document "free" in the sense of freedom: to
4507      assure everyone the effective freedom to copy and redistribute it,
4508      with or without modifying it, either commercially or
4509      noncommercially.  Secondarily, this License preserves for the
4510      author and publisher a way to get credit for their work, while not
4511      being considered responsible for modifications made by others.
4512
4513      This License is a kind of "copyleft", which means that derivative
4514      works of the document must themselves be free in the same sense.
4515      It complements the GNU General Public License, which is a copyleft
4516      license designed for free software.
4517
4518      We have designed this License in order to use it for manuals for
4519      free software, because free software needs free documentation: a
4520      free program should come with manuals providing the same freedoms
4521      that the software does.  But this License is not limited to
4522      software manuals; it can be used for any textual work, regardless
4523      of subject matter or whether it is published as a printed book.
4524      We recommend this License principally for works whose purpose is
4525      instruction or reference.
4526
4527   1. APPLICABILITY AND DEFINITIONS
4528
4529      This License applies to any manual or other work, in any medium,
4530      that contains a notice placed by the copyright holder saying it
4531      can be distributed under the terms of this License.  Such a notice
4532      grants a world-wide, royalty-free license, unlimited in duration,
4533      to use that work under the conditions stated herein.  The
4534      "Document", below, refers to any such manual or work.  Any member
4535      of the public is a licensee, and is addressed as "you".  You
4536      accept the license if you copy, modify or distribute the work in a
4537      way requiring permission under copyright law.
4538
4539      A "Modified Version" of the Document means any work containing the
4540      Document or a portion of it, either copied verbatim, or with
4541      modifications and/or translated into another language.
4542
4543      A "Secondary Section" is a named appendix or a front-matter section
4544      of the Document that deals exclusively with the relationship of the
4545      publishers or authors of the Document to the Document's overall
4546      subject (or to related matters) and contains nothing that could
4547      fall directly within that overall subject.  (Thus, if the Document
4548      is in part a textbook of mathematics, a Secondary Section may not
4549      explain any mathematics.)  The relationship could be a matter of
4550      historical connection with the subject or with related matters, or
4551      of legal, commercial, philosophical, ethical or political position
4552      regarding them.
4553
4554      The "Invariant Sections" are certain Secondary Sections whose
4555      titles are designated, as being those of Invariant Sections, in
4556      the notice that says that the Document is released under this
4557      License.  If a section does not fit the above definition of
4558      Secondary then it is not allowed to be designated as Invariant.
4559      The Document may contain zero Invariant Sections.  If the Document
4560      does not identify any Invariant Sections then there are none.
4561
4562      The "Cover Texts" are certain short passages of text that are
4563      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4564      that says that the Document is released under this License.  A
4565      Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4566      be at most 25 words.
4567
4568      A "Transparent" copy of the Document means a machine-readable copy,
4569      represented in a format whose specification is available to the
4570      general public, that is suitable for revising the document
4571      straightforwardly with generic text editors or (for images
4572      composed of pixels) generic paint programs or (for drawings) some
4573      widely available drawing editor, and that is suitable for input to
4574      text formatters or for automatic translation to a variety of
4575      formats suitable for input to text formatters.  A copy made in an
4576      otherwise Transparent file format whose markup, or absence of
4577      markup, has been arranged to thwart or discourage subsequent
4578      modification by readers is not Transparent.  An image format is
4579      not Transparent if used for any substantial amount of text.  A
4580      copy that is not "Transparent" is called "Opaque".
4581
4582      Examples of suitable formats for Transparent copies include plain
4583      ASCII without markup, Texinfo input format, LaTeX input format,
4584      SGML or XML using a publicly available DTD, and
4585      standard-conforming simple HTML, PostScript or PDF designed for
4586      human modification.  Examples of transparent image formats include
4587      PNG, XCF and JPG.  Opaque formats include proprietary formats that
4588      can be read and edited only by proprietary word processors, SGML or
4589      XML for which the DTD and/or processing tools are not generally
4590      available, and the machine-generated HTML, PostScript or PDF
4591      produced by some word processors for output purposes only.
4592
4593      The "Title Page" means, for a printed book, the title page itself,
4594      plus such following pages as are needed to hold, legibly, the
4595      material this License requires to appear in the title page.  For
4596      works in formats which do not have any title page as such, "Title
4597      Page" means the text near the most prominent appearance of the
4598      work's title, preceding the beginning of the body of the text.
4599
4600      The "publisher" means any person or entity that distributes copies
4601      of the Document to the public.
4602
4603      A section "Entitled XYZ" means a named subunit of the Document
4604      whose title either is precisely XYZ or contains XYZ in parentheses
4605      following text that translates XYZ in another language.  (Here XYZ
4606      stands for a specific section name mentioned below, such as
4607      "Acknowledgements", "Dedications", "Endorsements", or "History".)
4608      To "Preserve the Title" of such a section when you modify the
4609      Document means that it remains a section "Entitled XYZ" according
4610      to this definition.
4611
4612      The Document may include Warranty Disclaimers next to the notice
4613      which states that this License applies to the Document.  These
4614      Warranty Disclaimers are considered to be included by reference in
4615      this License, but only as regards disclaiming warranties: any other
4616      implication that these Warranty Disclaimers may have is void and
4617      has no effect on the meaning of this License.
4618
4619   2. VERBATIM COPYING
4620
4621      You may copy and distribute the Document in any medium, either
4622      commercially or noncommercially, provided that this License, the
4623      copyright notices, and the license notice saying this License
4624      applies to the Document are reproduced in all copies, and that you
4625      add no other conditions whatsoever to those of this License.  You
4626      may not use technical measures to obstruct or control the reading
4627      or further copying of the copies you make or distribute.  However,
4628      you may accept compensation in exchange for copies.  If you
4629      distribute a large enough number of copies you must also follow
4630      the conditions in section 3.
4631
4632      You may also lend copies, under the same conditions stated above,
4633      and you may publicly display copies.
4634
4635   3. COPYING IN QUANTITY
4636
4637      If you publish printed copies (or copies in media that commonly
4638      have printed covers) of the Document, numbering more than 100, and
4639      the Document's license notice requires Cover Texts, you must
4640      enclose the copies in covers that carry, clearly and legibly, all
4641      these Cover Texts: Front-Cover Texts on the front cover, and
4642      Back-Cover Texts on the back cover.  Both covers must also clearly
4643      and legibly identify you as the publisher of these copies.  The
4644      front cover must present the full title with all words of the
4645      title equally prominent and visible.  You may add other material
4646      on the covers in addition.  Copying with changes limited to the
4647      covers, as long as they preserve the title of the Document and
4648      satisfy these conditions, can be treated as verbatim copying in
4649      other respects.
4650
4651      If the required texts for either cover are too voluminous to fit
4652      legibly, you should put the first ones listed (as many as fit
4653      reasonably) on the actual cover, and continue the rest onto
4654      adjacent pages.
4655
4656      If you publish or distribute Opaque copies of the Document
4657      numbering more than 100, you must either include a
4658      machine-readable Transparent copy along with each Opaque copy, or
4659      state in or with each Opaque copy a computer-network location from
4660      which the general network-using public has access to download
4661      using public-standard network protocols a complete Transparent
4662      copy of the Document, free of added material.  If you use the
4663      latter option, you must take reasonably prudent steps, when you
4664      begin distribution of Opaque copies in quantity, to ensure that
4665      this Transparent copy will remain thus accessible at the stated
4666      location until at least one year after the last time you
4667      distribute an Opaque copy (directly or through your agents or
4668      retailers) of that edition to the public.
4669
4670      It is requested, but not required, that you contact the authors of
4671      the Document well before redistributing any large number of
4672      copies, to give them a chance to provide you with an updated
4673      version of the Document.
4674
4675   4. MODIFICATIONS
4676
4677      You may copy and distribute a Modified Version of the Document
4678      under the conditions of sections 2 and 3 above, provided that you
4679      release the Modified Version under precisely this License, with
4680      the Modified Version filling the role of the Document, thus
4681      licensing distribution and modification of the Modified Version to
4682      whoever possesses a copy of it.  In addition, you must do these
4683      things in the Modified Version:
4684
4685        A. Use in the Title Page (and on the covers, if any) a title
4686           distinct from that of the Document, and from those of
4687           previous versions (which should, if there were any, be listed
4688           in the History section of the Document).  You may use the
4689           same title as a previous version if the original publisher of
4690           that version gives permission.
4691
4692        B. List on the Title Page, as authors, one or more persons or
4693           entities responsible for authorship of the modifications in
4694           the Modified Version, together with at least five of the
4695           principal authors of the Document (all of its principal
4696           authors, if it has fewer than five), unless they release you
4697           from this requirement.
4698
4699        C. State on the Title page the name of the publisher of the
4700           Modified Version, as the publisher.
4701
4702        D. Preserve all the copyright notices of the Document.
4703
4704        E. Add an appropriate copyright notice for your modifications
4705           adjacent to the other copyright notices.
4706
4707        F. Include, immediately after the copyright notices, a license
4708           notice giving the public permission to use the Modified
4709           Version under the terms of this License, in the form shown in
4710           the Addendum below.
4711
4712        G. Preserve in that license notice the full lists of Invariant
4713           Sections and required Cover Texts given in the Document's
4714           license notice.
4715
4716        H. Include an unaltered copy of this License.
4717
4718        I. Preserve the section Entitled "History", Preserve its Title,
4719           and add to it an item stating at least the title, year, new
4720           authors, and publisher of the Modified Version as given on
4721           the Title Page.  If there is no section Entitled "History" in
4722           the Document, create one stating the title, year, authors,
4723           and publisher of the Document as given on its Title Page,
4724           then add an item describing the Modified Version as stated in
4725           the previous sentence.
4726
4727        J. Preserve the network location, if any, given in the Document
4728           for public access to a Transparent copy of the Document, and
4729           likewise the network locations given in the Document for
4730           previous versions it was based on.  These may be placed in
4731           the "History" section.  You may omit a network location for a
4732           work that was published at least four years before the
4733           Document itself, or if the original publisher of the version
4734           it refers to gives permission.
4735
4736        K. For any section Entitled "Acknowledgements" or "Dedications",
4737           Preserve the Title of the section, and preserve in the
4738           section all the substance and tone of each of the contributor
4739           acknowledgements and/or dedications given therein.
4740
4741        L. Preserve all the Invariant Sections of the Document,
4742           unaltered in their text and in their titles.  Section numbers
4743           or the equivalent are not considered part of the section
4744           titles.
4745
4746        M. Delete any section Entitled "Endorsements".  Such a section
4747           may not be included in the Modified Version.
4748
4749        N. Do not retitle any existing section to be Entitled
4750           "Endorsements" or to conflict in title with any Invariant
4751           Section.
4752
4753        O. Preserve any Warranty Disclaimers.
4754
4755      If the Modified Version includes new front-matter sections or
4756      appendices that qualify as Secondary Sections and contain no
4757      material copied from the Document, you may at your option
4758      designate some or all of these sections as invariant.  To do this,
4759      add their titles to the list of Invariant Sections in the Modified
4760      Version's license notice.  These titles must be distinct from any
4761      other section titles.
4762
4763      You may add a section Entitled "Endorsements", provided it contains
4764      nothing but endorsements of your Modified Version by various
4765      parties--for example, statements of peer review or that the text
4766      has been approved by an organization as the authoritative
4767      definition of a standard.
4768
4769      You may add a passage of up to five words as a Front-Cover Text,
4770      and a passage of up to 25 words as a Back-Cover Text, to the end
4771      of the list of Cover Texts in the Modified Version.  Only one
4772      passage of Front-Cover Text and one of Back-Cover Text may be
4773      added by (or through arrangements made by) any one entity.  If the
4774      Document already includes a cover text for the same cover,
4775      previously added by you or by arrangement made by the same entity
4776      you are acting on behalf of, you may not add another; but you may
4777      replace the old one, on explicit permission from the previous
4778      publisher that added the old one.
4779
4780      The author(s) and publisher(s) of the Document do not by this
4781      License give permission to use their names for publicity for or to
4782      assert or imply endorsement of any Modified Version.
4783
4784   5. COMBINING DOCUMENTS
4785
4786      You may combine the Document with other documents released under
4787      this License, under the terms defined in section 4 above for
4788      modified versions, provided that you include in the combination
4789      all of the Invariant Sections of all of the original documents,
4790      unmodified, and list them all as Invariant Sections of your
4791      combined work in its license notice, and that you preserve all
4792      their Warranty Disclaimers.
4793
4794      The combined work need only contain one copy of this License, and
4795      multiple identical Invariant Sections may be replaced with a single
4796      copy.  If there are multiple Invariant Sections with the same name
4797      but different contents, make the title of each such section unique
4798      by adding at the end of it, in parentheses, the name of the
4799      original author or publisher of that section if known, or else a
4800      unique number.  Make the same adjustment to the section titles in
4801      the list of Invariant Sections in the license notice of the
4802      combined work.
4803
4804      In the combination, you must combine any sections Entitled
4805      "History" in the various original documents, forming one section
4806      Entitled "History"; likewise combine any sections Entitled
4807      "Acknowledgements", and any sections Entitled "Dedications".  You
4808      must delete all sections Entitled "Endorsements."
4809
4810   6. COLLECTIONS OF DOCUMENTS
4811
4812      You may make a collection consisting of the Document and other
4813      documents released under this License, and replace the individual
4814      copies of this License in the various documents with a single copy
4815      that is included in the collection, provided that you follow the
4816      rules of this License for verbatim copying of each of the
4817      documents in all other respects.
4818
4819      You may extract a single document from such a collection, and
4820      distribute it individually under this License, provided you insert
4821      a copy of this License into the extracted document, and follow
4822      this License in all other respects regarding verbatim copying of
4823      that document.
4824
4825   7. AGGREGATION WITH INDEPENDENT WORKS
4826
4827      A compilation of the Document or its derivatives with other
4828      separate and independent documents or works, in or on a volume of
4829      a storage or distribution medium, is called an "aggregate" if the
4830      copyright resulting from the compilation is not used to limit the
4831      legal rights of the compilation's users beyond what the individual
4832      works permit.  When the Document is included in an aggregate, this
4833      License does not apply to the other works in the aggregate which
4834      are not themselves derivative works of the Document.
4835
4836      If the Cover Text requirement of section 3 is applicable to these
4837      copies of the Document, then if the Document is less than one half
4838      of the entire aggregate, the Document's Cover Texts may be placed
4839      on covers that bracket the Document within the aggregate, or the
4840      electronic equivalent of covers if the Document is in electronic
4841      form.  Otherwise they must appear on printed covers that bracket
4842      the whole aggregate.
4843
4844   8. TRANSLATION
4845
4846      Translation is considered a kind of modification, so you may
4847      distribute translations of the Document under the terms of section
4848      4.  Replacing Invariant Sections with translations requires special
4849      permission from their copyright holders, but you may include
4850      translations of some or all Invariant Sections in addition to the
4851      original versions of these Invariant Sections.  You may include a
4852      translation of this License, and all the license notices in the
4853      Document, and any Warranty Disclaimers, provided that you also
4854      include the original English version of this License and the
4855      original versions of those notices and disclaimers.  In case of a
4856      disagreement between the translation and the original version of
4857      this License or a notice or disclaimer, the original version will
4858      prevail.
4859
4860      If a section in the Document is Entitled "Acknowledgements",
4861      "Dedications", or "History", the requirement (section 4) to
4862      Preserve its Title (section 1) will typically require changing the
4863      actual title.
4864
4865   9. TERMINATION
4866
4867      You may not copy, modify, sublicense, or distribute the Document
4868      except as expressly provided under this License.  Any attempt
4869      otherwise to copy, modify, sublicense, or distribute it is void,
4870      and will automatically terminate your rights under this License.
4871
4872      However, if you cease all violation of this License, then your
4873      license from a particular copyright holder is reinstated (a)
4874      provisionally, unless and until the copyright holder explicitly
4875      and finally terminates your license, and (b) permanently, if the
4876      copyright holder fails to notify you of the violation by some
4877      reasonable means prior to 60 days after the cessation.
4878
4879      Moreover, your license from a particular copyright holder is
4880      reinstated permanently if the copyright holder notifies you of the
4881      violation by some reasonable means, this is the first time you have
4882      received notice of violation of this License (for any work) from
4883      that copyright holder, and you cure the violation prior to 30 days
4884      after your receipt of the notice.
4885
4886      Termination of your rights under this section does not terminate
4887      the licenses of parties who have received copies or rights from
4888      you under this License.  If your rights have been terminated and
4889      not permanently reinstated, receipt of a copy of some or all of
4890      the same material does not give you any rights to use it.
4891
4892  10. FUTURE REVISIONS OF THIS LICENSE
4893
4894      The Free Software Foundation may publish new, revised versions of
4895      the GNU Free Documentation License from time to time.  Such new
4896      versions will be similar in spirit to the present version, but may
4897      differ in detail to address new problems or concerns.  See
4898      `http://www.gnu.org/copyleft/'.
4899
4900      Each version of the License is given a distinguishing version
4901      number.  If the Document specifies that a particular numbered
4902      version of this License "or any later version" applies to it, you
4903      have the option of following the terms and conditions either of
4904      that specified version or of any later version that has been
4905      published (not as a draft) by the Free Software Foundation.  If
4906      the Document does not specify a version number of this License,
4907      you may choose any version ever published (not as a draft) by the
4908      Free Software Foundation.  If the Document specifies that a proxy
4909      can decide which future versions of this License can be used, that
4910      proxy's public statement of acceptance of a version permanently
4911      authorizes you to choose that version for the Document.
4912
4913  11. RELICENSING
4914
4915      "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
4916      World Wide Web server that publishes copyrightable works and also
4917      provides prominent facilities for anybody to edit those works.  A
4918      public wiki that anybody can edit is an example of such a server.
4919      A "Massive Multiauthor Collaboration" (or "MMC") contained in the
4920      site means any set of copyrightable works thus published on the MMC
4921      site.
4922
4923      "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
4924      license published by Creative Commons Corporation, a not-for-profit
4925      corporation with a principal place of business in San Francisco,
4926      California, as well as future copyleft versions of that license
4927      published by that same organization.
4928
4929      "Incorporate" means to publish or republish a Document, in whole or
4930      in part, as part of another Document.
4931
4932      An MMC is "eligible for relicensing" if it is licensed under this
4933      License, and if all works that were first published under this
4934      License somewhere other than this MMC, and subsequently
4935      incorporated in whole or in part into the MMC, (1) had no cover
4936      texts or invariant sections, and (2) were thus incorporated prior
4937      to November 1, 2008.
4938
4939      The operator of an MMC Site may republish an MMC contained in the
4940      site under CC-BY-SA on the same site at any time before August 1,
4941      2009, provided the MMC is eligible for relicensing.
4942
4943
4944 ADDENDUM: How to use this License for your documents
4945 ====================================================
4946
4947 To use this License in a document you have written, include a copy of
4948 the License in the document and put the following copyright and license
4949 notices just after the title page:
4950
4951        Copyright (C)  YEAR  YOUR NAME.
4952        Permission is granted to copy, distribute and/or modify this document
4953        under the terms of the GNU Free Documentation License, Version 1.3
4954        or any later version published by the Free Software Foundation;
4955        with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
4956        Texts.  A copy of the license is included in the section entitled ``GNU
4957        Free Documentation License''.
4958
4959    If you have Invariant Sections, Front-Cover Texts and Back-Cover
4960 Texts, replace the "with...Texts." line with this:
4961
4962          with the Invariant Sections being LIST THEIR TITLES, with
4963          the Front-Cover Texts being LIST, and with the Back-Cover Texts
4964          being LIST.
4965
4966    If you have Invariant Sections without Cover Texts, or some other
4967 combination of the three, merge those two alternatives to suit the
4968 situation.
4969
4970    If your document contains nontrivial examples of program code, we
4971 recommend releasing these examples in parallel under your choice of
4972 free software license, such as the GNU General Public License, to
4973 permit their use in free software.
4974
4975 \1f
4976 File: diff.info,  Node: Translations,  Next: Index,  Prev: Copying This Manual,  Up: Top
4977
4978 Appendix B Translations of This Manual
4979 **************************************
4980
4981 Nishio Futoshi of the GNUjdoc project has prepared a Japanese
4982 translation of this manual.  Its most recent version can be found at
4983 `http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/'.
4984
4985 \1f
4986 File: diff.info,  Node: Index,  Prev: Translations,  Up: Top
4987
4988 Appendix C Index
4989 ****************
4990
4991 \0\b[index\0\b]
4992 * Menu:
4993
4994 * ! output format:                       Context.             (line   6)
4995 * +- output format:                      Unified Format.      (line   6)
4996 * < output format:                       Normal.              (line   6)
4997 * <<<<<<< for marking conflicts:         Marking Conflicts.   (line   6)
4998 * _POSIX2_VERSION:                       Standards conformance.
4999                                                               (line  24)
5000 * aligning tab stops:                    Tabs.                (line   6)
5001 * alternate file names:                  Alternate Names.     (line   6)
5002 * backup file names:                     Backup Names.        (line   6)
5003 * backup file strategy:                  Backups.             (line   6)
5004 * binary file diff:                      Binary.              (line   6)
5005 * blank and tab difference suppression:  White Space.         (line   6)
5006 * blank line difference suppression:     Blank Lines.         (line   6)
5007 * brief difference reports:              Brief.               (line   6)
5008 * bug reports:                           Bugs.                (line   6)
5009 * C function headings:                   C Function Headings. (line   6)
5010 * C if-then-else output format:          If-then-else.        (line   6)
5011 * case difference suppression:           Case Folding.        (line   6)
5012 * ClearCase:                             Revision Control.    (line   6)
5013 * cmp invocation:                        Invoking cmp.        (line   6)
5014 * cmp options:                           cmp Options.         (line   6)
5015 * columnar output:                       Side by Side.        (line   6)
5016 * common mistakes with patches:          Avoiding Common Mistakes.
5017                                                               (line   6)
5018 * comparing three files:                 Comparing Three Files.
5019                                                               (line   6)
5020 * conflict:                              diff3 Merging.       (line  26)
5021 * conflict marking:                      Marking Conflicts.   (line   6)
5022 * context output format:                 Context.             (line   6)
5023 * creating files:                        Creating and Removing.
5024                                                               (line   6)
5025 * diagnostics from patch:                patch Messages.      (line   6)
5026 * diff invocation:                       Invoking diff.       (line   6)
5027 * diff merging:                          Interactive Merging. (line   6)
5028 * diff options:                          diff Options.        (line   6)
5029 * diff sample input:                     Sample diff Input.   (line   6)
5030 * diff3 hunks:                           diff3 Hunks.         (line   6)
5031 * diff3 invocation:                      Invoking diff3.      (line   6)
5032 * diff3 options:                         diff3 Options.       (line   6)
5033 * diff3 sample input:                    Sample diff3 Input.  (line   6)
5034 * directories and patch:                 patch Directories.   (line   6)
5035 * directory structure changes:           Changing Structure.  (line   6)
5036 * dry runs for patch:                    Dry Runs.            (line   6)
5037 * ed script output format:               ed Scripts.          (line   6)
5038 * EDITOR:                                Merge Commands.      (line  50)
5039 * empty files, removing:                 Creating and Removing.
5040                                                               (line   6)
5041 * exabyte, definition of:                cmp Options.         (line 106)
5042 * exbibyte, definition of:               cmp Options.         (line 110)
5043 * file name alternates:                  Alternate Names.     (line   6)
5044 * file names with unusual characters:    Unusual File Names.  (line   6)
5045 * format of diff output:                 Output Formats.      (line   6)
5046 * format of diff3 output:                Comparing Three Files.
5047                                                               (line   6)
5048 * formats for if-then-else line groups:  Line Group Formats.  (line   6)
5049 * forward ed script output format:       Forward ed.          (line   6)
5050 * full lines:                            Incomplete Lines.    (line   6)
5051 * function headings, C:                  C Function Headings. (line   6)
5052 * fuzz factor when patching:             Inexact.             (line   6)
5053 * gibibyte, definition of:               cmp Options.         (line  89)
5054 * gigabyte, definition of:               cmp Options.         (line  85)
5055 * headings:                              Sections.            (line   6)
5056 * hunks:                                 Hunks.               (line   6)
5057 * hunks for diff3:                       diff3 Hunks.         (line   6)
5058 * if-then-else output format:            If-then-else.        (line   6)
5059 * ifdef output format:                   If-then-else.        (line   6)
5060 * imperfect patch application:           Imperfect.           (line   6)
5061 * incomplete line merging:               Merging Incomplete Lines.
5062                                                               (line   6)
5063 * incomplete lines:                      Incomplete Lines.    (line   6)
5064 * inexact patches:                       Inexact.             (line   6)
5065 * inhibit messages from patch:           More or Fewer Messages.
5066                                                               (line   6)
5067 * interactive merging:                   Interactive Merging. (line   6)
5068 * introduction:                          Comparison.          (line   6)
5069 * intuiting file names from patches:     Multiple Patches.    (line   6)
5070 * invoking cmp:                          Invoking cmp.        (line   6)
5071 * invoking diff:                         Invoking diff.       (line   6)
5072 * invoking diff3:                        Invoking diff3.      (line   6)
5073 * invoking patch:                        Invoking patch.      (line   6)
5074 * invoking sdiff:                        Invoking sdiff.      (line   6)
5075 * keyboard input to patch:               patch and Keyboard Input.
5076                                                               (line   6)
5077 * kibibyte, definition of:               cmp Options.         (line  73)
5078 * kilobyte, definition of:               cmp Options.         (line  68)
5079 * LC_COLLATE:                            Comparing Directories.
5080                                                               (line   6)
5081 * LC_NUMERIC:                            Line Group Formats.  (line 144)
5082 * LC_TIME:                               Detailed Context.    (line  12)
5083 * line formats:                          Line Formats.        (line   6)
5084 * line group formats:                    Line Group Formats.  (line   6)
5085 * mebibyte, definition of:               cmp Options.         (line  82)
5086 * megabyte, definition of:               cmp Options.         (line  78)
5087 * merge commands:                        Merge Commands.      (line   6)
5088 * merged diff3 format:                   Bypassing ed.        (line   6)
5089 * merged output format:                  If-then-else.        (line   6)
5090 * merging from a common ancestor:        diff3 Merging.       (line   6)
5091 * merging interactively:                 Merge Commands.      (line   6)
5092 * messages from patch:                   patch Messages.      (line   6)
5093 * multibyte characters:                  Internationalization.
5094                                                               (line   6)
5095 * multiple patches:                      Multiple Patches.    (line   6)
5096 * newline treatment by diff:             Incomplete Lines.    (line   6)
5097 * normal output format:                  Normal.              (line   6)
5098 * options for cmp:                       cmp Options.         (line   6)
5099 * options for diff:                      diff Options.        (line   6)
5100 * options for diff3:                     diff3 Options.       (line   6)
5101 * options for patch:                     patch Options.       (line   6)
5102 * options for sdiff:                     sdiff Options.       (line   6)
5103 * output formats:                        Output Formats.      (line   6)
5104 * overlap:                               diff3 Merging.       (line  26)
5105 * overlapping change, selection of:      Which Changes.       (line   6)
5106 * overview of diff and patch:            Overview.            (line   6)
5107 * paginating diff output:                Pagination.          (line   6)
5108 * patch consumer tips:                   Tips for Patch Consumers.
5109                                                               (line   6)
5110 * patch input format:                    patch Input.         (line   6)
5111 * patch invocation:                      Invoking patch.      (line   6)
5112 * patch messages and questions:          patch Messages.      (line   6)
5113 * patch options:                         patch Options.       (line   6)
5114 * patch producer tips:                   Tips for Patch Producers.
5115                                                               (line   6)
5116 * patch, common mistakes:                Avoiding Common Mistakes.
5117                                                               (line   6)
5118 * PATCH_GET:                             Revision Control.    (line  13)
5119 * PATCH_VERSION_CONTROL:                 Backup Names.        (line  21)
5120 * patches, shrinking:                    Generating Smaller Patches.
5121                                                               (line   6)
5122 * patching directories:                  patch Directories.   (line   6)
5123 * pebibyte, definition of:               cmp Options.         (line 103)
5124 * performance of diff:                   diff Performance.    (line   6)
5125 * petabyte, definition of:               cmp Options.         (line  99)
5126 * POSIX <1>:                             Standards conformance.
5127                                                               (line   6)
5128 * POSIX:                                 patch and POSIX.     (line   6)
5129 * POSIXLY_CORRECT <1>:                   Standards conformance.
5130                                                               (line   6)
5131 * POSIXLY_CORRECT:                       patch and POSIX.     (line   6)
5132 * projects for directories:              Shortcomings.        (line   6)
5133 * quoting style:                         patch Quoting Style. (line   6)
5134 * QUOTING_STYLE:                         patch Quoting Style. (line  30)
5135 * RCS:                                   Revision Control.    (line   6)
5136 * RCS script output format:              RCS.                 (line   6)
5137 * regular expression matching headings:  Specified Headings.  (line   6)
5138 * regular expression suppression:        Specified Lines.     (line   6)
5139 * reject file names:                     Reject Names.        (line   6)
5140 * removing empty files:                  Creating and Removing.
5141                                                               (line   6)
5142 * reporting bugs:                        Bugs.                (line   6)
5143 * reversed patches:                      Reversed Patches.    (line   6)
5144 * revision control:                      Revision Control.    (line   6)
5145 * sample input for diff:                 Sample diff Input.   (line   6)
5146 * sample input for diff3:                Sample diff3 Input.  (line   6)
5147 * SCCS:                                  Revision Control.    (line   6)
5148 * script output formats:                 Scripts.             (line   6)
5149 * sdiff invocation:                      Invoking sdiff.      (line   6)
5150 * sdiff options:                         sdiff Options.       (line   6)
5151 * sdiff output format:                   sdiff Option Summary.
5152                                                               (line   6)
5153 * section headings:                      Sections.            (line   6)
5154 * side by side:                          Side by Side.        (line   6)
5155 * side by side format:                   Side by Side Format. (line   6)
5156 * SIMPLE_BACKUP_SUFFIX:                  Backup Names.        (line  12)
5157 * special files:                         Special Files.       (line   6)
5158 * specified headings:                    Specified Headings.  (line   6)
5159 * summarizing which files differ:        Brief.               (line   6)
5160 * System V diff3 compatibility:          Saving the Changed File.
5161                                                               (line   6)
5162 * tab and blank difference suppression:  White Space.         (line   6)
5163 * tab stop alignment:                    Tabs.                (line   6)
5164 * tebibyte, definition of:               cmp Options.         (line  96)
5165 * terabyte, definition of:               cmp Options.         (line  92)
5166 * testing patch:                         Dry Runs.            (line   6)
5167 * text versus binary diff:               Binary.              (line   6)
5168 * time stamp format, context diffs:      Detailed Context.    (line  12)
5169 * time stamp format, unified diffs:      Detailed Unified.    (line  12)
5170 * time stamps on patched files:          Patching Time Stamps.
5171                                                               (line   6)
5172 * traditional patch:                     patch and Tradition. (line   6)
5173 * trailing blanks:                       Trailing Blanks.     (line   6)
5174 * two-column output:                     Side by Side.        (line   6)
5175 * unified output format:                 Unified Format.      (line   6)
5176 * unmerged change:                       Which Changes.       (line   6)
5177 * varying-width characters:              Internationalization.
5178                                                               (line   6)
5179 * verbose messages from patch:           More or Fewer Messages.
5180                                                               (line   6)
5181 * version control:                       Revision Control.    (line   6)
5182 * VERSION_CONTROL <1>:                   Backup Names.        (line  21)
5183 * VERSION_CONTROL:                       Revision Control.    (line  22)
5184 * white space in patches:                Changed White Space. (line   6)
5185 * yottabyte, definition of:              cmp Options.         (line 121)
5186 * zettabyte, definition of:              cmp Options.         (line 113)
5187
5188
5189 \1f
5190 Tag Table:
5191 Node: Top\7f1675
5192 Node: Overview\7f4135
5193 Node: Comparison\7f7759
5194 Node: Hunks\7f10457
5195 Node: White Space\7f11895
5196 Node: Blank Lines\7f13623
5197 Node: Specified Lines\7f14653
5198 Node: Case Folding\7f15775
5199 Node: Brief\7f16187
5200 Node: Binary\7f17506
5201 Node: Output Formats\7f21591
5202 Node: Sample diff Input\7f22311
5203 Node: Context\7f23805
5204 Node: Context Format\7f25377
5205 Node: Example Context\7f26164
5206 Node: Less Context\7f27666
5207 Node: Detailed Context\7f28850
5208 Node: Unified Format\7f31043
5209 Node: Example Unified\7f31834
5210 Node: Detailed Unified\7f32867
5211 Node: Sections\7f34509
5212 Node: Specified Headings\7f35263
5213 Node: C Function Headings\7f36812
5214 Node: Alternate Names\7f37654
5215 Node: Side by Side\7f38563
5216 Node: Side by Side Format\7f40707
5217 Node: Example Side by Side\7f41605
5218 Node: Normal\7f42940
5219 Node: Example Normal\7f43935
5220 Node: Detailed Normal\7f44666
5221 Node: Scripts\7f46400
5222 Node: ed Scripts\7f46800
5223 Node: Example ed\7f48002
5224 Node: Detailed ed\7f48447
5225 Node: Forward ed\7f50201
5226 Node: RCS\7f50972
5227 Node: If-then-else\7f52184
5228 Node: Line Group Formats\7f53857
5229 Node: Line Formats\7f59728
5230 Node: Example If-then-else\7f62993
5231 Node: Detailed If-then-else\7f64067
5232 Node: Incomplete Lines\7f65945
5233 Node: Comparing Directories\7f67577
5234 Node: Adjusting Output\7f71621
5235 Node: Tabs\7f72123
5236 Node: Trailing Blanks\7f73733
5237 Node: Pagination\7f74954
5238 Node: diff Performance\7f75418
5239 Node: Comparing Three Files\7f78501
5240 Node: Sample diff3 Input\7f79374
5241 Node: Example diff3 Normal\7f80317
5242 Node: Detailed diff3 Normal\7f81362
5243 Node: diff3 Hunks\7f83117
5244 Node: diff3 Merging\7f84408
5245 Node: Which Changes\7f86647
5246 Node: Marking Conflicts\7f88046
5247 Node: Bypassing ed\7f90500
5248 Node: Merging Incomplete Lines\7f91839
5249 Node: Saving the Changed File\7f92560
5250 Node: Interactive Merging\7f93171
5251 Node: sdiff Option Summary\7f93876
5252 Node: Merge Commands\7f95047
5253 Node: Merging with patch\7f96331
5254 Node: patch Input\7f98698
5255 Node: Revision Control\7f99375
5256 Node: Imperfect\7f100541
5257 Node: Changed White Space\7f101684
5258 Node: Reversed Patches\7f102476
5259 Node: Inexact\7f103936
5260 Node: Dry Runs\7f107490
5261 Node: Creating and Removing\7f108349
5262 Node: Patching Time Stamps\7f109395
5263 Node: Multiple Patches\7f111593
5264 Node: patch Directories\7f114251
5265 Node: Backups\7f115872
5266 Node: Backup Names\7f116933
5267 Ref: Backup Names-Footnote-1\7f119897
5268 Node: Reject Names\7f120024
5269 Node: patch Messages\7f120608
5270 Node: More or Fewer Messages\7f121663
5271 Node: patch and Keyboard Input\7f122289
5272 Node: patch Quoting Style\7f123315
5273 Node: patch and POSIX\7f124460
5274 Node: patch and Tradition\7f125295
5275 Node: Making Patches\7f128747
5276 Node: Tips for Patch Producers\7f129568
5277 Node: Tips for Patch Consumers\7f130819
5278 Node: Avoiding Common Mistakes\7f131451
5279 Node: Generating Smaller Patches\7f133971
5280 Node: Invoking cmp\7f135727
5281 Node: cmp Options\7f137145
5282 Node: Invoking diff\7f140632
5283 Node: diff Options\7f142485
5284 Node: Invoking diff3\7f150912
5285 Node: diff3 Options\7f151545
5286 Node: Invoking patch\7f154573
5287 Node: patch Options\7f155776
5288 Node: Invoking sdiff\7f160998
5289 Node: sdiff Options\7f162140
5290 Node: Standards conformance\7f165015
5291 Node: Projects\7f166756
5292 Node: Shortcomings\7f167462
5293 Node: Internationalization\7f168559
5294 Node: Changing Structure\7f169720
5295 Node: Special Files\7f170819
5296 Node: Unusual File Names\7f171926
5297 Node: Time Stamp Order\7f172560
5298 Node: Ignoring Changes\7f173198
5299 Node: Speedups\7f173963
5300 Node: Bugs\7f174422
5301 Node: Copying This Manual\7f175270
5302 Node: Translations\7f200404
5303 Node: Index\7f200771
5304 \1f
5305 End Tag Table