1*6ea1f93eSDaniel FojtThis is diffutils.info, produced by makeinfo version 6.5 from
2008e37b6SJohn Marinodiffutils.texi.
3008e37b6SJohn Marino
4*6ea1f93eSDaniel FojtThis manual is for GNU Diffutils (version 3.7, 7 January 2018), and
5*6ea1f93eSDaniel Fojtdocuments the GNU 'diff', 'diff3', 'sdiff', and 'cmp' commands for
6*6ea1f93eSDaniel Fojtshowing the differences between files and the GNU 'patch' command for
7008e37b6SJohn Marinousing their output to update files.
8008e37b6SJohn Marino
9*6ea1f93eSDaniel Fojt   Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2018 Free
10008e37b6SJohn MarinoSoftware Foundation, Inc.
11008e37b6SJohn Marino
12008e37b6SJohn Marino     Permission is granted to copy, distribute and/or modify this
13008e37b6SJohn Marino     document under the terms of the GNU Free Documentation License,
14008e37b6SJohn Marino     Version 1.3 or any later version published by the Free Software
15008e37b6SJohn Marino     Foundation; with no Invariant Sections, no Front-Cover Texts, and
16008e37b6SJohn Marino     no Back-Cover Texts.  A copy of the license is included in the
17008e37b6SJohn Marino     section entitled "GNU Free Documentation License."
18008e37b6SJohn MarinoINFO-DIR-SECTION Individual utilities
19008e37b6SJohn MarinoSTART-INFO-DIR-ENTRY
20008e37b6SJohn Marino* cmp: (diffutils)Invoking cmp.                 Compare 2 files byte by byte.
21008e37b6SJohn Marino* diff: (diffutils)Invoking diff.               Compare 2 files line by line.
22008e37b6SJohn Marino* diff3: (diffutils)Invoking diff3.             Compare 3 files line by line.
23008e37b6SJohn Marino* patch: (diffutils)Invoking patch.             Apply a patch to a file.
24008e37b6SJohn Marino* sdiff: (diffutils)Invoking sdiff.             Merge 2 files side-by-side.
25008e37b6SJohn MarinoEND-INFO-DIR-ENTRY
26008e37b6SJohn Marino
27008e37b6SJohn MarinoINFO-DIR-SECTION Text creation and manipulation
28008e37b6SJohn MarinoSTART-INFO-DIR-ENTRY
29008e37b6SJohn Marino* Diffutils: (diffutils).       Comparing and merging files.
30008e37b6SJohn MarinoEND-INFO-DIR-ENTRY
31008e37b6SJohn Marino
32008e37b6SJohn Marino
33*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Top,  Next: Overview,  Up: (dir)
34008e37b6SJohn Marino
35008e37b6SJohn MarinoComparing and Merging Files
36008e37b6SJohn Marino***************************
37008e37b6SJohn Marino
38*6ea1f93eSDaniel FojtThis manual is for GNU Diffutils (version 3.7, 7 January 2018), and
39*6ea1f93eSDaniel Fojtdocuments the GNU 'diff', 'diff3', 'sdiff', and 'cmp' commands for
40*6ea1f93eSDaniel Fojtshowing the differences between files and the GNU 'patch' command for
41008e37b6SJohn Marinousing their output to update files.
42008e37b6SJohn Marino
43*6ea1f93eSDaniel Fojt   Copyright (C) 1992-1994, 1998, 2001-2002, 2004, 2006, 2009-2018 Free
44008e37b6SJohn MarinoSoftware Foundation, Inc.
45008e37b6SJohn Marino
46008e37b6SJohn Marino     Permission is granted to copy, distribute and/or modify this
47008e37b6SJohn Marino     document under the terms of the GNU Free Documentation License,
48008e37b6SJohn Marino     Version 1.3 or any later version published by the Free Software
49008e37b6SJohn Marino     Foundation; with no Invariant Sections, no Front-Cover Texts, and
50008e37b6SJohn Marino     no Back-Cover Texts.  A copy of the license is included in the
51008e37b6SJohn Marino     section entitled "GNU Free Documentation License."
52008e37b6SJohn Marino
53008e37b6SJohn Marino* Menu:
54008e37b6SJohn Marino
55008e37b6SJohn Marino* Overview::              Preliminary information.
56008e37b6SJohn Marino* Comparison::            What file comparison means.
57008e37b6SJohn Marino
58008e37b6SJohn Marino* Output Formats::        Formats for two-way difference reports.
59008e37b6SJohn Marino* Incomplete Lines::      Lines that lack trailing newlines.
60008e37b6SJohn Marino* Comparing Directories:: Comparing files and directories.
61*6ea1f93eSDaniel Fojt* Adjusting Output::      Making 'diff' output prettier.
62*6ea1f93eSDaniel Fojt* diff Performance::      Making 'diff' smarter or faster.
63008e37b6SJohn Marino
64008e37b6SJohn Marino* Comparing Three Files:: Formats for three-way difference reports.
65008e37b6SJohn Marino* diff3 Merging::         Merging from a common ancestor.
66008e37b6SJohn Marino
67*6ea1f93eSDaniel Fojt* Interactive Merging::   Interactive merging with 'sdiff'.
68008e37b6SJohn Marino
69*6ea1f93eSDaniel Fojt* Merging with patch::    Using 'patch' to change old files into new ones.
70008e37b6SJohn Marino* Making Patches::        Tips for making and using patch distributions.
71008e37b6SJohn Marino
72008e37b6SJohn Marino* Invoking cmp::          Compare two files byte by byte.
73008e37b6SJohn Marino* Invoking diff::         Compare two files line by line.
74008e37b6SJohn Marino* Invoking diff3::        Compare three files line by line.
75008e37b6SJohn Marino* Invoking patch::        Apply a diff file to an original.
76008e37b6SJohn Marino* Invoking sdiff::        Side-by-side merge of file differences.
77008e37b6SJohn Marino
78008e37b6SJohn Marino* Standards conformance:: Conformance to the POSIX standard.
79008e37b6SJohn Marino* Projects::              If you've found a bug or other shortcoming.
80008e37b6SJohn Marino
81008e37b6SJohn Marino* Copying This Manual::   How to make copies of this manual.
82008e37b6SJohn Marino* Translations::          Available translations of this manual.
83008e37b6SJohn Marino* Index::                 Index.
84008e37b6SJohn Marino
85008e37b6SJohn Marino
86*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Overview,  Next: Comparison,  Prev: Top,  Up: Top
87008e37b6SJohn Marino
88008e37b6SJohn MarinoOverview
89008e37b6SJohn Marino********
90008e37b6SJohn Marino
91008e37b6SJohn MarinoComputer users often find occasion to ask how two files differ.  Perhaps
92008e37b6SJohn Marinoone file is a newer version of the other file.  Or maybe the two files
93008e37b6SJohn Marinostarted out as identical copies but were changed by different people.
94008e37b6SJohn Marino
95*6ea1f93eSDaniel Fojt   You can use the 'diff' command to show differences between two files,
96*6ea1f93eSDaniel Fojtor each corresponding file in two directories.  'diff' outputs
97008e37b6SJohn Marinodifferences between files line by line in any of several formats,
98008e37b6SJohn Marinoselectable by command line options.  This set of differences is often
99*6ea1f93eSDaniel Fojtcalled a "diff" or "patch".  For files that are identical, 'diff'
100*6ea1f93eSDaniel Fojtnormally produces no output; for binary (non-text) files, 'diff'
101008e37b6SJohn Marinonormally reports only that they are different.
102008e37b6SJohn Marino
103*6ea1f93eSDaniel Fojt   You can use the 'cmp' command to show the byte and line numbers where
104*6ea1f93eSDaniel Fojttwo files differ.  'cmp' can also show all the bytes that differ between
105*6ea1f93eSDaniel Fojtthe two files, side by side.  A way to compare two files character by
106*6ea1f93eSDaniel Fojtcharacter is the Emacs command 'M-x compare-windows'.  *Note Other
107*6ea1f93eSDaniel FojtWindow: (emacs)Other Window, for more information on that command.
108008e37b6SJohn Marino
109*6ea1f93eSDaniel Fojt   You can use the 'diff3' command to show differences among three
110008e37b6SJohn Marinofiles.  When two people have made independent changes to a common
111*6ea1f93eSDaniel Fojtoriginal, 'diff3' can report the differences between the original and
112008e37b6SJohn Marinothe two changed versions, and can produce a merged file that contains
113008e37b6SJohn Marinoboth persons' changes together with warnings about conflicts.
114008e37b6SJohn Marino
115*6ea1f93eSDaniel Fojt   You can use the 'sdiff' command to merge two files interactively.
116008e37b6SJohn Marino
117*6ea1f93eSDaniel Fojt   You can use the set of differences produced by 'diff' to distribute
118008e37b6SJohn Marinoupdates to text files (such as program source code) to other people.
119008e37b6SJohn MarinoThis method is especially useful when the differences are small compared
120*6ea1f93eSDaniel Fojtto the complete files.  Given 'diff' output, you can use the 'patch'
121008e37b6SJohn Marinoprogram to update, or "patch", a copy of the file.  If you think of
122*6ea1f93eSDaniel Fojt'diff' as subtracting one file from another to produce their difference,
123*6ea1f93eSDaniel Fojtyou can think of 'patch' as adding the difference to one file to
124*6ea1f93eSDaniel Fojtreproduce the other.
125008e37b6SJohn Marino
126008e37b6SJohn Marino   This manual first concentrates on making diffs, and later shows how
127008e37b6SJohn Marinoto use diffs to update files.
128008e37b6SJohn Marino
129*6ea1f93eSDaniel Fojt   GNU 'diff' was written by Paul Eggert, Mike Haertel, David Hayes,
130*6ea1f93eSDaniel FojtRichard Stallman, and Len Tower.  Wayne Davison designed and implemented
131*6ea1f93eSDaniel Fojtthe unified output format.  The basic algorithm is described by Eugene
132*6ea1f93eSDaniel FojtW. Myers in "An O(ND) Difference Algorithm and its Variations",
133*6ea1f93eSDaniel Fojt'Algorithmica' Vol. 1, 1986, pp. 251-266,
134*6ea1f93eSDaniel Fojt<http://dx.doi.org/10.1007/BF01840446>; and in "A File Comparison
135*6ea1f93eSDaniel FojtProgram", Webb Miller and Eugene W. Myers, 'Software--Practice and
136*6ea1f93eSDaniel FojtExperience' Vol. 15, 1985, pp. 1025-1040,
137*6ea1f93eSDaniel Fojt<http://dx.doi.org/10.1002/spe.4380151102>.  The algorithm was
138*6ea1f93eSDaniel Fojtindependently discovered as described by Esko Ukkonen in "Algorithms for
139*6ea1f93eSDaniel FojtApproximate String Matching", 'Information and Control' Vol. 64, 1985,
140*6ea1f93eSDaniel Fojtpp. 100-118, <http://dx.doi.org/10.1016/S0019-9958(85)80046-2>.  Unless
141*6ea1f93eSDaniel Fojtthe '--minimal' option is used, 'diff' uses a heuristic by Paul Eggert
142*6ea1f93eSDaniel Fojtthat limits the cost to O(N^1.5 log N) at the price of producing
143*6ea1f93eSDaniel Fojtsuboptimal output for large inputs with many differences.  Related
144*6ea1f93eSDaniel Fojtalgorithms are surveyed by Alfred V. Aho in section 6.3 of "Algorithms
145*6ea1f93eSDaniel Fojtfor Finding Patterns in Strings", 'Handbook of Theoretical Computer
146*6ea1f93eSDaniel FojtScience' (Jan Van Leeuwen, ed.), Vol. A, 'Algorithms and Complexity',
147*6ea1f93eSDaniel FojtElsevier/MIT Press, 1990, pp. 255-300.
148008e37b6SJohn Marino
149*6ea1f93eSDaniel Fojt   GNU 'diff3' was written by Randy Smith.  GNU 'sdiff' was written by
150*6ea1f93eSDaniel FojtThomas Lord.  GNU 'cmp' was written by Torbjo"rn Granlund and David
151008e37b6SJohn MarinoMacKenzie.
152008e37b6SJohn Marino
153*6ea1f93eSDaniel Fojt   GNU 'patch' was written mainly by Larry Wall and Paul Eggert; several
154*6ea1f93eSDaniel FojtGNU enhancements were contributed by Wayne Davison and David MacKenzie.
155*6ea1f93eSDaniel FojtParts of this manual are adapted from a manual page written by Larry
156*6ea1f93eSDaniel FojtWall, with his permission.
157008e37b6SJohn Marino
158008e37b6SJohn Marino
159*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Comparison,  Next: Output Formats,  Prev: Overview,  Up: Top
160008e37b6SJohn Marino
161008e37b6SJohn Marino1 What Comparison Means
162008e37b6SJohn Marino***********************
163008e37b6SJohn Marino
164008e37b6SJohn MarinoThere are several ways to think about the differences between two files.
165008e37b6SJohn MarinoOne way to think of the differences is as a series of lines that were
166008e37b6SJohn Marinodeleted from, inserted in, or changed in one file to produce the other
167*6ea1f93eSDaniel Fojtfile.  'diff' compares two files line by line, finds groups of lines
168008e37b6SJohn Marinothat differ, and reports each group of differing lines.  It can report
169008e37b6SJohn Marinothe differing lines in several formats, which have different purposes.
170008e37b6SJohn Marino
171*6ea1f93eSDaniel Fojt   GNU 'diff' can show whether files are different without detailing the
172*6ea1f93eSDaniel Fojtdifferences.  It also provides ways to suppress certain kinds of
173008e37b6SJohn Marinodifferences that are not important to you.  Most commonly, such
174008e37b6SJohn Marinodifferences are changes in the amount of white space between words or
175*6ea1f93eSDaniel Fojtlines.  'diff' also provides ways to suppress differences in alphabetic
176008e37b6SJohn Marinocase or in lines that match a regular expression that you provide.
177008e37b6SJohn MarinoThese options can accumulate; for example, you can ignore changes in
178008e37b6SJohn Marinoboth white space and alphabetic case.
179008e37b6SJohn Marino
180008e37b6SJohn Marino   Another way to think of the differences between two files is as a
181008e37b6SJohn Marinosequence of pairs of bytes that can be either identical or different.
182*6ea1f93eSDaniel Fojt'cmp' reports the differences between two files byte by byte, instead of
183*6ea1f93eSDaniel Fojtline by line.  As a result, it is often more useful than 'diff' for
184*6ea1f93eSDaniel Fojtcomparing binary files.  For text files, 'cmp' is useful mainly when you
185*6ea1f93eSDaniel Fojtwant to know only whether two files are identical, or whether one file
186*6ea1f93eSDaniel Fojtis a prefix of the other.
187008e37b6SJohn Marino
188008e37b6SJohn Marino   To illustrate the effect that considering changes byte by byte can
189008e37b6SJohn Marinohave compared with considering them line by line, think of what happens
190008e37b6SJohn Marinoif a single newline character is added to the beginning of a file.  If
191008e37b6SJohn Marinothat file is then compared with an otherwise identical file that lacks
192*6ea1f93eSDaniel Fojtthe newline at the beginning, 'diff' will report that a blank line has
193*6ea1f93eSDaniel Fojtbeen added to the file, while 'cmp' will report that almost every byte
194008e37b6SJohn Marinoof the two files differs.
195008e37b6SJohn Marino
196*6ea1f93eSDaniel Fojt   'diff3' normally compares three input files line by line, finds
197008e37b6SJohn Marinogroups of lines that differ, and reports each group of differing lines.
198008e37b6SJohn MarinoIts output is designed to make it easy to inspect two different sets of
199008e37b6SJohn Marinochanges to the same file.
200008e37b6SJohn Marino
201*6ea1f93eSDaniel Fojt   These commands compare input files without necessarily reading them.
202*6ea1f93eSDaniel FojtFor example, if 'diff' is asked simply to report whether two files
203*6ea1f93eSDaniel Fojtdiffer, and it discovers that the files have different sizes, it need
204*6ea1f93eSDaniel Fojtnot read them to do its job.
205*6ea1f93eSDaniel Fojt
206008e37b6SJohn Marino* Menu:
207008e37b6SJohn Marino
208008e37b6SJohn Marino* Hunks::             Groups of differing lines.
209008e37b6SJohn Marino* White Space::       Suppressing differences in white space.
210008e37b6SJohn Marino* Blank Lines::       Suppressing differences whose lines are all blank.
211008e37b6SJohn Marino* Specified Lines::   Suppressing differences whose lines all match a pattern.
212008e37b6SJohn Marino* Case Folding::      Suppressing differences in alphabetic case.
213008e37b6SJohn Marino* Brief::             Summarizing which files are different.
214008e37b6SJohn Marino* Binary::            Comparing binary files or forcing text comparisons.
215008e37b6SJohn Marino
216008e37b6SJohn Marino
217*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Hunks,  Next: White Space,  Up: Comparison
218008e37b6SJohn Marino
219008e37b6SJohn Marino1.1 Hunks
220008e37b6SJohn Marino=========
221008e37b6SJohn Marino
222*6ea1f93eSDaniel FojtWhen comparing two files, 'diff' finds sequences of lines common to both
223*6ea1f93eSDaniel Fojtfiles, interspersed with groups of differing lines called "hunks".
224*6ea1f93eSDaniel FojtComparing two identical files yields one sequence of common lines and no
225*6ea1f93eSDaniel Fojthunks, because no lines differ.  Comparing two entirely different files
226*6ea1f93eSDaniel Fojtyields no common lines and one large hunk that contains all lines of
227*6ea1f93eSDaniel Fojtboth files.  In general, there are many ways to match up lines between
228*6ea1f93eSDaniel Fojttwo given files.  'diff' tries to minimize the total hunk size by
229*6ea1f93eSDaniel Fojtfinding large sequences of common lines interspersed with small hunks of
230*6ea1f93eSDaniel Fojtdiffering lines.
231008e37b6SJohn Marino
232*6ea1f93eSDaniel Fojt   For example, suppose the file 'F' contains the three lines 'a', 'b',
233*6ea1f93eSDaniel Fojt'c', and the file 'G' contains the same three lines in reverse order
234*6ea1f93eSDaniel Fojt'c', 'b', 'a'.  If 'diff' finds the line 'c' as common, then the command
235*6ea1f93eSDaniel Fojt'diff F G' produces this output:
236008e37b6SJohn Marino
237008e37b6SJohn Marino     1,2d0
238008e37b6SJohn Marino     < a
239008e37b6SJohn Marino     < b
240008e37b6SJohn Marino     3a2,3
241008e37b6SJohn Marino     > b
242008e37b6SJohn Marino     > a
243008e37b6SJohn Marino
244*6ea1f93eSDaniel FojtBut if 'diff' notices the common line 'b' instead, it produces this
245008e37b6SJohn Marinooutput:
246008e37b6SJohn Marino
247008e37b6SJohn Marino     1c1
248008e37b6SJohn Marino     < a
249008e37b6SJohn Marino     ---
250008e37b6SJohn Marino     > c
251008e37b6SJohn Marino     3c3
252008e37b6SJohn Marino     < c
253008e37b6SJohn Marino     ---
254008e37b6SJohn Marino     > a
255008e37b6SJohn Marino
256*6ea1f93eSDaniel FojtIt is also possible to find 'a' as the common line.  'diff' does not
257*6ea1f93eSDaniel Fojtalways find an optimal matching between the files; it takes shortcuts to
258*6ea1f93eSDaniel Fojtrun faster.  But its output is usually close to the shortest possible.
259*6ea1f93eSDaniel FojtYou can adjust this tradeoff with the '--minimal' ('-d') option (*note
260*6ea1f93eSDaniel Fojtdiff Performance::).
261008e37b6SJohn Marino
262008e37b6SJohn Marino
263*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: White Space,  Next: Blank Lines,  Prev: Hunks,  Up: Comparison
264008e37b6SJohn Marino
265008e37b6SJohn Marino1.2 Suppressing Differences in Blank and Tab Spacing
266008e37b6SJohn Marino====================================================
267008e37b6SJohn Marino
268*6ea1f93eSDaniel FojtThe '--ignore-tab-expansion' ('-E') option ignores the distinction
269008e37b6SJohn Marinobetween tabs and spaces on input.  A tab is considered to be equivalent
270008e37b6SJohn Marinoto the number of spaces to the next tab stop (*note Tabs::).
271008e37b6SJohn Marino
272*6ea1f93eSDaniel Fojt   The '--ignore-trailing-space' ('-Z') option ignores white space at
273008e37b6SJohn Marinoline end.
274008e37b6SJohn Marino
275*6ea1f93eSDaniel Fojt   The '--ignore-space-change' ('-b') option is stronger than '-E' and
276*6ea1f93eSDaniel Fojt'-Z' combined.  It ignores white space at line end, and considers all
277008e37b6SJohn Marinoother sequences of one or more white space characters within a line to
278*6ea1f93eSDaniel Fojtbe equivalent.  With this option, 'diff' considers the following two
279*6ea1f93eSDaniel Fojtlines to be equivalent, where '$' denotes the line end:
280008e37b6SJohn Marino
281008e37b6SJohn Marino     Here lyeth  muche rychnesse  in lytell space.   -- John Heywood$
282008e37b6SJohn Marino     Here lyeth muche rychnesse in lytell space. -- John Heywood   $
283008e37b6SJohn Marino
284*6ea1f93eSDaniel Fojt   The '--ignore-all-space' ('-w') option is stronger still.  It ignores
285*6ea1f93eSDaniel Fojtdifferences even if one line has white space where the other line has
286*6ea1f93eSDaniel Fojtnone.  "White space" characters include tab, vertical tab, form feed,
287*6ea1f93eSDaniel Fojtcarriage return, and space; some locales may define additional
288*6ea1f93eSDaniel Fojtcharacters to be white space.  With this option, 'diff' considers the
289*6ea1f93eSDaniel Fojtfollowing two lines to be equivalent, where '$' denotes the line end and
290*6ea1f93eSDaniel Fojt'^M' denotes a carriage return:
291008e37b6SJohn Marino
292008e37b6SJohn Marino     Here lyeth  muche  rychnesse in lytell space.--  John Heywood$
293008e37b6SJohn Marino       He relyeth much erychnes  seinly tells pace.  --John Heywood   ^M$
294008e37b6SJohn Marino
295008e37b6SJohn Marino   For many other programs newline is also a white space character, but
296*6ea1f93eSDaniel Fojt'diff' is a line-oriented program and a newline character always ends a
297*6ea1f93eSDaniel Fojtline.  Hence the '-w' or '--ignore-all-space' option does not ignore
298008e37b6SJohn Marinonewline-related changes; it ignores only other white space changes.
299008e37b6SJohn Marino
300008e37b6SJohn Marino
301*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Blank Lines,  Next: Specified Lines,  Prev: White Space,  Up: Comparison
302008e37b6SJohn Marino
303008e37b6SJohn Marino1.3 Suppressing Differences Whose Lines Are All Blank
304008e37b6SJohn Marino=====================================================
305008e37b6SJohn Marino
306*6ea1f93eSDaniel FojtThe '--ignore-blank-lines' ('-B') option ignores changes that consist
307008e37b6SJohn Marinoentirely of blank lines.  With this option, for example, a file
308008e37b6SJohn Marinocontaining
309008e37b6SJohn Marino     1.  A point is that which has no part.
310008e37b6SJohn Marino
311008e37b6SJohn Marino     2.  A line is breadthless length.
312008e37b6SJohn Marino     -- Euclid, The Elements, I
313008e37b6SJohn Marinois considered identical to a file containing
314008e37b6SJohn Marino     1.  A point is that which has no part.
315008e37b6SJohn Marino     2.  A line is breadthless length.
316008e37b6SJohn Marino
317008e37b6SJohn Marino
318008e37b6SJohn Marino     -- Euclid, The Elements, I
319008e37b6SJohn Marino
320008e37b6SJohn Marino   Normally this option affects only lines that are completely empty,
321008e37b6SJohn Marinobut if you also specify an option that ignores trailing spaces, lines
322008e37b6SJohn Marinoare also affected if they look empty but contain white space.  In other
323*6ea1f93eSDaniel Fojtwords, '-B' is equivalent to '-I '^$'' by default, but it is equivalent
324*6ea1f93eSDaniel Fojtto '-I '^[[:space:]]*$'' if '-b', '-w' or '-Z' is also specified.
325008e37b6SJohn Marino
326008e37b6SJohn Marino
327*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Specified Lines,  Next: Case Folding,  Prev: Blank Lines,  Up: Comparison
328008e37b6SJohn Marino
329008e37b6SJohn Marino1.4 Suppressing Differences Whose Lines All Match a Regular Expression
330008e37b6SJohn Marino======================================================================
331008e37b6SJohn Marino
332*6ea1f93eSDaniel FojtTo ignore insertions and deletions of lines that match a 'grep'-style
333*6ea1f93eSDaniel Fojtregular expression, use the '--ignore-matching-lines=REGEXP' ('-I
334008e37b6SJohn MarinoREGEXP') option.  You should escape regular expressions that contain
335008e37b6SJohn Marinoshell metacharacters to prevent the shell from expanding them.  For
336*6ea1f93eSDaniel Fojtexample, 'diff -I '^[[:digit:]]'' ignores all changes to lines beginning
337*6ea1f93eSDaniel Fojtwith a digit.
338008e37b6SJohn Marino
339*6ea1f93eSDaniel Fojt   However, '-I' only ignores the insertion or deletion of lines that
340008e37b6SJohn Marinocontain the regular expression if every changed line in the hunk--every
341008e37b6SJohn Marinoinsertion and every deletion--matches the regular expression.  In other
342*6ea1f93eSDaniel Fojtwords, for each nonignorable change, 'diff' prints the complete set of
343008e37b6SJohn Marinochanges in its vicinity, including the ignorable ones.
344008e37b6SJohn Marino
345008e37b6SJohn Marino   You can specify more than one regular expression for lines to ignore
346*6ea1f93eSDaniel Fojtby using more than one '-I' option.  'diff' tries to match each line
347008e37b6SJohn Marinoagainst each regular expression.
348008e37b6SJohn Marino
349008e37b6SJohn Marino
350*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Case Folding,  Next: Brief,  Prev: Specified Lines,  Up: Comparison
351008e37b6SJohn Marino
352008e37b6SJohn Marino1.5 Suppressing Case Differences
353008e37b6SJohn Marino================================
354008e37b6SJohn Marino
355*6ea1f93eSDaniel FojtGNU 'diff' can treat lower case letters as equivalent to their upper
356*6ea1f93eSDaniel Fojtcase counterparts, so that, for example, it considers 'Funky Stuff',
357*6ea1f93eSDaniel Fojt'funky STUFF', and 'fUNKy stuFf' to all be the same.  To request this,
358*6ea1f93eSDaniel Fojtuse the '-i' or '--ignore-case' option.
359008e37b6SJohn Marino
360008e37b6SJohn Marino
361*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Brief,  Next: Binary,  Prev: Case Folding,  Up: Comparison
362008e37b6SJohn Marino
363008e37b6SJohn Marino1.6 Summarizing Which Files Differ
364008e37b6SJohn Marino==================================
365008e37b6SJohn Marino
366008e37b6SJohn MarinoWhen you only want to find out whether files are different, and you
367008e37b6SJohn Marinodon't care what the differences are, you can use the summary output
368008e37b6SJohn Marinoformat.  In this format, instead of showing the differences between the
369*6ea1f93eSDaniel Fojtfiles, 'diff' simply reports whether files differ.  The '--brief' ('-q')
370*6ea1f93eSDaniel Fojtoption selects this output format.
371008e37b6SJohn Marino
372008e37b6SJohn Marino   This format is especially useful when comparing the contents of two
373008e37b6SJohn Marinodirectories.  It is also much faster than doing the normal line by line
374*6ea1f93eSDaniel Fojtcomparisons, because 'diff' can stop analyzing the files as soon as it
375008e37b6SJohn Marinoknows that there are any differences.
376008e37b6SJohn Marino
377008e37b6SJohn Marino   You can also get a brief indication of whether two files differ by
378*6ea1f93eSDaniel Fojtusing 'cmp'.  For files that are identical, 'cmp' produces no output.
379*6ea1f93eSDaniel FojtWhen the files differ, by default, 'cmp' outputs the byte and line
380008e37b6SJohn Marinonumber where the first difference occurs, or reports that one file is a
381*6ea1f93eSDaniel Fojtprefix of the other.  You can use the '-s', '--quiet', or '--silent'
382*6ea1f93eSDaniel Fojtoption to suppress that information, so that 'cmp' produces no output
383008e37b6SJohn Marinoand reports whether the files differ using only its exit status (*note
384008e37b6SJohn MarinoInvoking cmp::).
385008e37b6SJohn Marino
386*6ea1f93eSDaniel Fojt   Unlike 'diff', 'cmp' cannot compare directories; it can only compare
387008e37b6SJohn Marinotwo files.
388008e37b6SJohn Marino
389008e37b6SJohn Marino
390*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Binary,  Prev: Brief,  Up: Comparison
391008e37b6SJohn Marino
392008e37b6SJohn Marino1.7 Binary Files and Forcing Text Comparisons
393008e37b6SJohn Marino=============================================
394008e37b6SJohn Marino
395*6ea1f93eSDaniel FojtIf 'diff' thinks that either of the two files it is comparing is binary
396008e37b6SJohn Marino(a non-text file), it normally treats that pair of files much as if the
397008e37b6SJohn Marinosummary output format had been selected (*note Brief::), and reports
398008e37b6SJohn Marinoonly that the binary files are different.  This is because line by line
399*6ea1f93eSDaniel Fojtcomparisons are usually not meaningful for binary files.  This does not
400*6ea1f93eSDaniel Fojtcount as trouble, even though the resulting output does not capture all
401*6ea1f93eSDaniel Fojtthe differences.
402008e37b6SJohn Marino
403*6ea1f93eSDaniel Fojt   'diff' determines whether a file is text or binary by checking the
404008e37b6SJohn Marinofirst few bytes in the file; the exact number of bytes is system
405008e37b6SJohn Marinodependent, but it is typically several thousand.  If every byte in that
406*6ea1f93eSDaniel Fojtpart of the file is non-null, 'diff' considers the file to be text;
407008e37b6SJohn Marinootherwise it considers the file to be binary.
408008e37b6SJohn Marino
409*6ea1f93eSDaniel Fojt   Sometimes you might want to force 'diff' to consider files to be
410008e37b6SJohn Marinotext.  For example, you might be comparing text files that contain null
411*6ea1f93eSDaniel Fojtcharacters; 'diff' would erroneously decide that those are non-text
412*6ea1f93eSDaniel Fojtfiles.  Or you might be comparing documents that are in a format used by
413*6ea1f93eSDaniel Fojta word processing system that uses null characters to indicate special
414*6ea1f93eSDaniel Fojtformatting.  You can force 'diff' to consider all files to be text
415*6ea1f93eSDaniel Fojtfiles, and compare them line by line, by using the '--text' ('-a')
416008e37b6SJohn Marinooption.  If the files you compare using this option do not in fact
417*6ea1f93eSDaniel Fojtcontain text, they will probably contain few newline characters, and the
418*6ea1f93eSDaniel Fojt'diff' output will consist of hunks showing differences between long
419*6ea1f93eSDaniel Fojtlines of whatever characters the files contain.
420008e37b6SJohn Marino
421*6ea1f93eSDaniel Fojt   You can also force 'diff' to report only whether files differ (but
422*6ea1f93eSDaniel Fojtnot how).  Use the '--brief' ('-q') option for this.
423008e37b6SJohn Marino
424008e37b6SJohn Marino   In operating systems that distinguish between text and binary files,
425*6ea1f93eSDaniel Fojt'diff' normally reads and writes all data as text.  Use the '--binary'
426*6ea1f93eSDaniel Fojtoption to force 'diff' to read and write binary data instead.  This
427*6ea1f93eSDaniel Fojtoption has no effect on a POSIX-compliant system like GNU or traditional
428*6ea1f93eSDaniel FojtUnix.  However, many personal computer operating systems represent the
429*6ea1f93eSDaniel Fojtend of a line with a carriage return followed by a newline.  On such
430*6ea1f93eSDaniel Fojtsystems, 'diff' normally ignores these carriage returns on input and
431*6ea1f93eSDaniel Fojtgenerates them at the end of each output line, but with the '--binary'
432*6ea1f93eSDaniel Fojtoption 'diff' treats each carriage return as just another input
433*6ea1f93eSDaniel Fojtcharacter, and does not generate a carriage return at the end of each
434*6ea1f93eSDaniel Fojtoutput line.  This can be useful when dealing with non-text files that
435*6ea1f93eSDaniel Fojtare meant to be interchanged with POSIX-compliant systems.
436008e37b6SJohn Marino
437*6ea1f93eSDaniel Fojt   The '--strip-trailing-cr' causes 'diff' to treat input lines that end
438*6ea1f93eSDaniel Fojtin carriage return followed by newline as if they end in plain newline.
439*6ea1f93eSDaniel FojtThis can be useful when comparing text that is imperfectly imported from
440*6ea1f93eSDaniel Fojtmany personal computer operating systems.  This option affects how lines
441*6ea1f93eSDaniel Fojtare read, which in turn affects how they are compared and output.
442008e37b6SJohn Marino
443*6ea1f93eSDaniel Fojt   If you want to compare two files byte by byte, you can use the 'cmp'
444*6ea1f93eSDaniel Fojtprogram with the '--verbose' ('-l') option to show the values of each
445*6ea1f93eSDaniel Fojtdiffering byte in the two files.  With GNU 'cmp', you can also use the
446*6ea1f93eSDaniel Fojt'-b' or '--print-bytes' option to show the ASCII representation of those
447*6ea1f93eSDaniel Fojtbytes.  *Note Invoking cmp::, for more information.
448008e37b6SJohn Marino
449*6ea1f93eSDaniel Fojt   If 'diff3' thinks that any of the files it is comparing is binary (a
450008e37b6SJohn Marinonon-text file), it normally reports an error, because such comparisons
451*6ea1f93eSDaniel Fojtare usually not useful.  'diff3' uses the same test as 'diff' to decide
452*6ea1f93eSDaniel Fojtwhether a file is binary.  As with 'diff', if the input files contain a
453008e37b6SJohn Marinofew non-text bytes but otherwise are like text files, you can force
454*6ea1f93eSDaniel Fojt'diff3' to consider all files to be text files and compare them line by
455*6ea1f93eSDaniel Fojtline by using the '-a' or '--text' option.
456008e37b6SJohn Marino
457008e37b6SJohn Marino
458*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Output Formats,  Next: Incomplete Lines,  Prev: Comparison,  Up: Top
459008e37b6SJohn Marino
460*6ea1f93eSDaniel Fojt2 'diff' Output Formats
461008e37b6SJohn Marino***********************
462008e37b6SJohn Marino
463*6ea1f93eSDaniel Fojt'diff' has several mutually exclusive options for output format.  The
464*6ea1f93eSDaniel Fojtfollowing sections describe each format, illustrating how 'diff' reports
465*6ea1f93eSDaniel Fojtthe differences between two sample input files.
466008e37b6SJohn Marino
467008e37b6SJohn Marino* Menu:
468008e37b6SJohn Marino
469*6ea1f93eSDaniel Fojt* Sample diff Input:: Sample 'diff' input files for examples.
470008e37b6SJohn Marino* Context::           Showing differences with the surrounding text.
471008e37b6SJohn Marino* Side by Side::      Showing differences in two columns.
472008e37b6SJohn Marino* Normal::            Showing differences without surrounding text.
473008e37b6SJohn Marino* Scripts::           Generating scripts for other programs.
474008e37b6SJohn Marino* If-then-else::      Merging files with if-then-else.
475008e37b6SJohn Marino
476008e37b6SJohn Marino
477*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Sample diff Input,  Next: Context,  Up: Output Formats
478008e37b6SJohn Marino
479008e37b6SJohn Marino2.1 Two Sample Input Files
480008e37b6SJohn Marino==========================
481008e37b6SJohn Marino
482008e37b6SJohn MarinoHere are two sample files that we will use in numerous examples to
483*6ea1f93eSDaniel Fojtillustrate the output of 'diff' and how various options can change it.
484008e37b6SJohn Marino
485*6ea1f93eSDaniel Fojt   This is the file 'lao':
486008e37b6SJohn Marino
487008e37b6SJohn Marino     The Way that can be told of is not the eternal Way;
488008e37b6SJohn Marino     The name that can be named is not the eternal name.
489008e37b6SJohn Marino     The Nameless is the origin of Heaven and Earth;
490008e37b6SJohn Marino     The Named is the mother of all things.
491008e37b6SJohn Marino     Therefore let there always be non-being,
492008e37b6SJohn Marino       so we may see their subtlety,
493008e37b6SJohn Marino     And let there always be being,
494008e37b6SJohn Marino       so we may see their outcome.
495008e37b6SJohn Marino     The two are the same,
496008e37b6SJohn Marino     But after they are produced,
497008e37b6SJohn Marino       they have different names.
498008e37b6SJohn Marino
499*6ea1f93eSDaniel Fojt   This is the file 'tzu':
500008e37b6SJohn Marino
501008e37b6SJohn Marino     The Nameless is the origin of Heaven and Earth;
502008e37b6SJohn Marino     The named is the mother of all things.
503008e37b6SJohn Marino
504008e37b6SJohn Marino     Therefore let there always be non-being,
505008e37b6SJohn Marino       so we may see their subtlety,
506008e37b6SJohn Marino     And let there always be being,
507008e37b6SJohn Marino       so we may see their outcome.
508008e37b6SJohn Marino     The two are the same,
509008e37b6SJohn Marino     But after they are produced,
510008e37b6SJohn Marino       they have different names.
511008e37b6SJohn Marino     They both may be called deep and profound.
512008e37b6SJohn Marino     Deeper and more profound,
513008e37b6SJohn Marino     The door of all subtleties!
514008e37b6SJohn Marino
515008e37b6SJohn Marino   In this example, the first hunk contains just the first two lines of
516*6ea1f93eSDaniel Fojt'lao', the second hunk contains the fourth line of 'lao' opposing the
517*6ea1f93eSDaniel Fojtsecond and third lines of 'tzu', and the last hunk contains just the
518*6ea1f93eSDaniel Fojtlast three lines of 'tzu'.
519008e37b6SJohn Marino
520008e37b6SJohn Marino
521*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Context,  Next: Side by Side,  Prev: Sample diff Input,  Up: Output Formats
522008e37b6SJohn Marino
523008e37b6SJohn Marino2.2 Showing Differences in Their Context
524008e37b6SJohn Marino========================================
525008e37b6SJohn Marino
526008e37b6SJohn MarinoUsually, when you are looking at the differences between files, you will
527008e37b6SJohn Marinoalso want to see the parts of the files near the lines that differ, to
528008e37b6SJohn Marinohelp you understand exactly what has changed.  These nearby parts of the
529008e37b6SJohn Marinofiles are called the "context".
530008e37b6SJohn Marino
531*6ea1f93eSDaniel Fojt   GNU 'diff' provides two output formats that show context around the
532008e37b6SJohn Marinodiffering lines: "context format" and "unified format".  It can
533008e37b6SJohn Marinooptionally show in which function or section of the file the differing
534008e37b6SJohn Marinolines are found.
535008e37b6SJohn Marino
536008e37b6SJohn Marino   If you are distributing new versions of files to other people in the
537*6ea1f93eSDaniel Fojtform of 'diff' output, you should use one of the output formats that
538008e37b6SJohn Marinoshow context so that they can apply the diffs even if they have made
539*6ea1f93eSDaniel Fojtsmall changes of their own to the files.  'patch' can apply the diffs in
540*6ea1f93eSDaniel Fojtthis case by searching in the files for the lines of context around the
541*6ea1f93eSDaniel Fojtdiffering lines; if those lines are actually a few lines away from where
542*6ea1f93eSDaniel Fojtthe diff says they are, 'patch' can adjust the line numbers accordingly
543*6ea1f93eSDaniel Fojtand still apply the diff correctly.  *Note Imperfect::, for more
544*6ea1f93eSDaniel Fojtinformation on using 'patch' to apply imperfect diffs.
545008e37b6SJohn Marino
546008e37b6SJohn Marino* Menu:
547008e37b6SJohn Marino
548008e37b6SJohn Marino* Context Format::  An output format that shows surrounding lines.
549008e37b6SJohn Marino* Unified Format::  A more compact output format that shows context.
550008e37b6SJohn Marino* Sections::        Showing which sections of the files differences are in.
551008e37b6SJohn Marino* Alternate Names:: Showing alternate file names in context headers.
552008e37b6SJohn Marino
553008e37b6SJohn Marino
554*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Context Format,  Next: Unified Format,  Up: Context
555008e37b6SJohn Marino
556008e37b6SJohn Marino2.2.1 Context Format
557008e37b6SJohn Marino--------------------
558008e37b6SJohn Marino
559008e37b6SJohn MarinoThe context output format shows several lines of context around the
560008e37b6SJohn Marinolines that differ.  It is the standard format for distributing updates
561008e37b6SJohn Marinoto source code.
562008e37b6SJohn Marino
563*6ea1f93eSDaniel Fojt   To select this output format, use the '--context[=LINES]' ('-C
564*6ea1f93eSDaniel FojtLINES') or '-c' option.  The argument LINES that some of these options
565008e37b6SJohn Marinotake is the number of lines of context to show.  If you do not specify
566*6ea1f93eSDaniel FojtLINES, it defaults to three.  For proper operation, 'patch' typically
567008e37b6SJohn Marinoneeds at least two lines of context.
568008e37b6SJohn Marino
569008e37b6SJohn Marino* Menu:
570008e37b6SJohn Marino
571008e37b6SJohn Marino* Example Context::  Sample output in context format.
572008e37b6SJohn Marino* Less Context::     Another sample with less context.
573008e37b6SJohn Marino* Detailed Context:: A detailed description of the context output format.
574008e37b6SJohn Marino
575008e37b6SJohn Marino
576*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example Context,  Next: Less Context,  Up: Context Format
577008e37b6SJohn Marino
578008e37b6SJohn Marino2.2.1.1 An Example of Context Format
579008e37b6SJohn Marino....................................
580008e37b6SJohn Marino
581*6ea1f93eSDaniel FojtHere is the output of 'diff -c lao tzu' (*note Sample diff Input::, for
582008e37b6SJohn Marinothe complete contents of the two files).  Notice that up to three lines
583008e37b6SJohn Marinothat are not different are shown around each line that is different;
584008e37b6SJohn Marinothey are the context lines.  Also notice that the first two hunks have
585008e37b6SJohn Marinorun together, because their contents overlap.
586008e37b6SJohn Marino
587008e37b6SJohn Marino     *** lao	2002-02-21 23:30:39.942229878 -0800
588008e37b6SJohn Marino     --- tzu	2002-02-21 23:30:50.442260588 -0800
589008e37b6SJohn Marino     ***************
590008e37b6SJohn Marino     *** 1,7 ****
591008e37b6SJohn Marino     - The Way that can be told of is not the eternal Way;
592008e37b6SJohn Marino     - The name that can be named is not the eternal name.
593008e37b6SJohn Marino       The Nameless is the origin of Heaven and Earth;
594008e37b6SJohn Marino     ! The Named is the mother of all things.
595008e37b6SJohn Marino       Therefore let there always be non-being,
596008e37b6SJohn Marino         so we may see their subtlety,
597008e37b6SJohn Marino       And let there always be being,
598008e37b6SJohn Marino     --- 1,6 ----
599008e37b6SJohn Marino       The Nameless is the origin of Heaven and Earth;
600008e37b6SJohn Marino     ! The named is the mother of all things.
601008e37b6SJohn Marino     !
602008e37b6SJohn Marino       Therefore let there always be non-being,
603008e37b6SJohn Marino         so we may see their subtlety,
604008e37b6SJohn Marino       And let there always be being,
605008e37b6SJohn Marino     ***************
606008e37b6SJohn Marino     *** 9,11 ****
607008e37b6SJohn Marino     --- 8,13 ----
608008e37b6SJohn Marino       The two are the same,
609008e37b6SJohn Marino       But after they are produced,
610008e37b6SJohn Marino         they have different names.
611008e37b6SJohn Marino     + They both may be called deep and profound.
612008e37b6SJohn Marino     + Deeper and more profound,
613008e37b6SJohn Marino     + The door of all subtleties!
614008e37b6SJohn Marino
615008e37b6SJohn Marino
616*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Less Context,  Next: Detailed Context,  Prev: Example Context,  Up: Context Format
617008e37b6SJohn Marino
618008e37b6SJohn Marino2.2.1.2 An Example of Context Format with Less Context
619008e37b6SJohn Marino......................................................
620008e37b6SJohn Marino
621*6ea1f93eSDaniel FojtHere is the output of 'diff -C 1 lao tzu' (*note Sample diff Input::,
622008e37b6SJohn Marinofor the complete contents of the two files).  Notice that at most one
623008e37b6SJohn Marinocontext line is reported here.
624008e37b6SJohn Marino
625008e37b6SJohn Marino     *** lao	2002-02-21 23:30:39.942229878 -0800
626008e37b6SJohn Marino     --- tzu	2002-02-21 23:30:50.442260588 -0800
627008e37b6SJohn Marino     ***************
628008e37b6SJohn Marino     *** 1,5 ****
629008e37b6SJohn Marino     - The Way that can be told of is not the eternal Way;
630008e37b6SJohn Marino     - The name that can be named is not the eternal name.
631008e37b6SJohn Marino       The Nameless is the origin of Heaven and Earth;
632008e37b6SJohn Marino     ! The Named is the mother of all things.
633008e37b6SJohn Marino       Therefore let there always be non-being,
634008e37b6SJohn Marino     --- 1,4 ----
635008e37b6SJohn Marino       The Nameless is the origin of Heaven and Earth;
636008e37b6SJohn Marino     ! The named is the mother of all things.
637008e37b6SJohn Marino     !
638008e37b6SJohn Marino       Therefore let there always be non-being,
639008e37b6SJohn Marino     ***************
640008e37b6SJohn Marino     *** 11 ****
641008e37b6SJohn Marino     --- 10,13 ----
642008e37b6SJohn Marino         they have different names.
643008e37b6SJohn Marino     + They both may be called deep and profound.
644008e37b6SJohn Marino     + Deeper and more profound,
645008e37b6SJohn Marino     + The door of all subtleties!
646008e37b6SJohn Marino
647008e37b6SJohn Marino
648*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Detailed Context,  Prev: Less Context,  Up: Context Format
649008e37b6SJohn Marino
650008e37b6SJohn Marino2.2.1.3 Detailed Description of Context Format
651008e37b6SJohn Marino..............................................
652008e37b6SJohn Marino
653008e37b6SJohn MarinoThe context output format starts with a two-line header, which looks
654008e37b6SJohn Marinolike this:
655008e37b6SJohn Marino
656008e37b6SJohn Marino     *** FROM-FILE FROM-FILE-MODIFICATION-TIME
657008e37b6SJohn Marino     --- TO-FILE TO-FILE-MODIFICATION TIME
658008e37b6SJohn Marino
659*6ea1f93eSDaniel FojtThe timestamp normally looks like '2002-02-21 23:30:39.942229878 -0800'
660*6ea1f93eSDaniel Fojtto indicate the date, time with fractional seconds, and time zone in
661*6ea1f93eSDaniel FojtInternet RFC 2822 format (ftp://ftp.isi.edu/in-notes/rfc2822.txt).  (The
662*6ea1f93eSDaniel Fojtfractional seconds are omitted on hosts that do not support fractional
663*6ea1f93eSDaniel Fojttimestamps.)  However, a traditional timestamp like 'Thu Feb 21 23:30:39
664*6ea1f93eSDaniel Fojt2002' is used if the 'LC_TIME' locale category is either 'C' or 'POSIX'.
665008e37b6SJohn Marino
666*6ea1f93eSDaniel Fojt   You can change the header's content with the '--label=LABEL' option;
667008e37b6SJohn Marinosee *note Alternate Names::.
668008e37b6SJohn Marino
669008e37b6SJohn Marino   Next come one or more hunks of differences; each hunk shows one area
670008e37b6SJohn Marinowhere the files differ.  Context format hunks look like this:
671008e37b6SJohn Marino
672008e37b6SJohn Marino     ***************
673008e37b6SJohn Marino     *** FROM-FILE-LINE-NUMBERS ****
674008e37b6SJohn Marino       FROM-FILE-LINE
675008e37b6SJohn Marino       FROM-FILE-LINE...
676008e37b6SJohn Marino     --- TO-FILE-LINE-NUMBERS ----
677008e37b6SJohn Marino       TO-FILE-LINE
678008e37b6SJohn Marino       TO-FILE-LINE...
679008e37b6SJohn Marino
680008e37b6SJohn Marino   If a hunk contains two or more lines, its line numbers look like
681*6ea1f93eSDaniel Fojt'START,END'.  Otherwise only its end line number appears.  An empty hunk
682*6ea1f93eSDaniel Fojtis considered to end at the line that precedes the hunk.
683008e37b6SJohn Marino
684008e37b6SJohn Marino   The lines of context around the lines that differ start with two
685008e37b6SJohn Marinospace characters.  The lines that differ between the two files start
686008e37b6SJohn Marinowith one of the following indicator characters, followed by a space
687008e37b6SJohn Marinocharacter:
688008e37b6SJohn Marino
689*6ea1f93eSDaniel Fojt'!'
690008e37b6SJohn Marino     A line that is part of a group of one or more lines that changed
691008e37b6SJohn Marino     between the two files.  There is a corresponding group of lines
692*6ea1f93eSDaniel Fojt     marked with '!' in the part of this hunk for the other file.
693008e37b6SJohn Marino
694*6ea1f93eSDaniel Fojt'+'
695008e37b6SJohn Marino     An "inserted" line in the second file that corresponds to nothing
696008e37b6SJohn Marino     in the first file.
697008e37b6SJohn Marino
698*6ea1f93eSDaniel Fojt'-'
699008e37b6SJohn Marino     A "deleted" line in the first file that corresponds to nothing in
700008e37b6SJohn Marino     the second file.
701008e37b6SJohn Marino
702008e37b6SJohn Marino   If all of the changes in a hunk are insertions, the lines of
703008e37b6SJohn MarinoFROM-FILE are omitted.  If all of the changes are deletions, the lines
704008e37b6SJohn Marinoof TO-FILE are omitted.
705008e37b6SJohn Marino
706008e37b6SJohn Marino
707*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Unified Format,  Next: Sections,  Prev: Context Format,  Up: Context
708008e37b6SJohn Marino
709008e37b6SJohn Marino2.2.2 Unified Format
710008e37b6SJohn Marino--------------------
711008e37b6SJohn Marino
712008e37b6SJohn MarinoThe unified output format is a variation on the context format that is
713008e37b6SJohn Marinomore compact because it omits redundant context lines.  To select this
714*6ea1f93eSDaniel Fojtoutput format, use the '--unified[=LINES]' ('-U LINES'), or '-u' option.
715008e37b6SJohn MarinoThe argument LINES is the number of lines of context to show.  When it
716008e37b6SJohn Marinois not given, it defaults to three.
717008e37b6SJohn Marino
718*6ea1f93eSDaniel Fojt   At present, only GNU 'diff' can produce this format and only GNU
719*6ea1f93eSDaniel Fojt'patch' can automatically apply diffs in this format.  For proper
720*6ea1f93eSDaniel Fojtoperation, 'patch' typically needs at least three lines of context.
721008e37b6SJohn Marino
722008e37b6SJohn Marino* Menu:
723008e37b6SJohn Marino
724008e37b6SJohn Marino* Example Unified::  Sample output in unified format.
725008e37b6SJohn Marino* Detailed Unified:: A detailed description of unified format.
726008e37b6SJohn Marino
727008e37b6SJohn Marino
728*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example Unified,  Next: Detailed Unified,  Up: Unified Format
729008e37b6SJohn Marino
730008e37b6SJohn Marino2.2.2.1 An Example of Unified Format
731008e37b6SJohn Marino....................................
732008e37b6SJohn Marino
733*6ea1f93eSDaniel FojtHere is the output of the command 'diff -u lao tzu' (*note Sample diff
734008e37b6SJohn MarinoInput::, for the complete contents of the two files):
735008e37b6SJohn Marino
736008e37b6SJohn Marino     --- lao	2002-02-21 23:30:39.942229878 -0800
737008e37b6SJohn Marino     +++ tzu	2002-02-21 23:30:50.442260588 -0800
738008e37b6SJohn Marino     @@ -1,7 +1,6 @@
739008e37b6SJohn Marino     -The Way that can be told of is not the eternal Way;
740008e37b6SJohn Marino     -The name that can be named is not the eternal name.
741008e37b6SJohn Marino      The Nameless is the origin of Heaven and Earth;
742008e37b6SJohn Marino     -The Named is the mother of all things.
743008e37b6SJohn Marino     +The named is the mother of all things.
744008e37b6SJohn Marino     +
745008e37b6SJohn Marino      Therefore let there always be non-being,
746008e37b6SJohn Marino        so we may see their subtlety,
747008e37b6SJohn Marino      And let there always be being,
748008e37b6SJohn Marino     @@ -9,3 +8,6 @@
749008e37b6SJohn Marino      The two are the same,
750008e37b6SJohn Marino      But after they are produced,
751008e37b6SJohn Marino        they have different names.
752008e37b6SJohn Marino     +They both may be called deep and profound.
753008e37b6SJohn Marino     +Deeper and more profound,
754008e37b6SJohn Marino     +The door of all subtleties!
755008e37b6SJohn Marino
756008e37b6SJohn Marino
757*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Detailed Unified,  Prev: Example Unified,  Up: Unified Format
758008e37b6SJohn Marino
759008e37b6SJohn Marino2.2.2.2 Detailed Description of Unified Format
760008e37b6SJohn Marino..............................................
761008e37b6SJohn Marino
762008e37b6SJohn MarinoThe unified output format starts with a two-line header, which looks
763008e37b6SJohn Marinolike this:
764008e37b6SJohn Marino
765008e37b6SJohn Marino     --- FROM-FILE FROM-FILE-MODIFICATION-TIME
766008e37b6SJohn Marino     +++ TO-FILE TO-FILE-MODIFICATION-TIME
767008e37b6SJohn Marino
768*6ea1f93eSDaniel FojtThe timestamp looks like '2002-02-21 23:30:39.942229878 -0800' to
769008e37b6SJohn Marinoindicate the date, time with fractional seconds, and time zone.  The
770008e37b6SJohn Marinofractional seconds are omitted on hosts that do not support fractional
771008e37b6SJohn Marinotimestamps.
772008e37b6SJohn Marino
773*6ea1f93eSDaniel Fojt   You can change the header's content with the '--label=LABEL' option.
7744536c563SJohn Marino*Note Alternate Names::.
775008e37b6SJohn Marino
776008e37b6SJohn Marino   Next come one or more hunks of differences; each hunk shows one area
777008e37b6SJohn Marinowhere the files differ.  Unified format hunks look like this:
778008e37b6SJohn Marino
779008e37b6SJohn Marino     @@ FROM-FILE-LINE-NUMBERS TO-FILE-LINE-NUMBERS @@
780008e37b6SJohn Marino      LINE-FROM-EITHER-FILE
781008e37b6SJohn Marino      LINE-FROM-EITHER-FILE...
782008e37b6SJohn Marino
783008e37b6SJohn Marino   If a hunk contains just one line, only its start line number appears.
784*6ea1f93eSDaniel FojtOtherwise its line numbers look like 'START,COUNT'.  An empty hunk is
785008e37b6SJohn Marinoconsidered to start at the line that follows the hunk.
786008e37b6SJohn Marino
787*6ea1f93eSDaniel Fojt   If a hunk and its context contain two or more lines, its line numbers
788*6ea1f93eSDaniel Fojtlook like 'START,COUNT'.  Otherwise only its end line number appears.
789*6ea1f93eSDaniel FojtAn empty hunk is considered to end at the line that precedes the hunk.
790008e37b6SJohn Marino
791008e37b6SJohn Marino   The lines common to both files begin with a space character.  The
792008e37b6SJohn Marinolines that actually differ between the two files have one of the
793008e37b6SJohn Marinofollowing indicator characters in the left print column:
794008e37b6SJohn Marino
795*6ea1f93eSDaniel Fojt'+'
796008e37b6SJohn Marino     A line was added here to the first file.
797008e37b6SJohn Marino
798*6ea1f93eSDaniel Fojt'-'
799008e37b6SJohn Marino     A line was removed here from the first file.
800008e37b6SJohn Marino
801008e37b6SJohn Marino
802*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Sections,  Next: Alternate Names,  Prev: Unified Format,  Up: Context
803008e37b6SJohn Marino
804008e37b6SJohn Marino2.2.3 Showing Which Sections Differences Are in
805008e37b6SJohn Marino-----------------------------------------------
806008e37b6SJohn Marino
807008e37b6SJohn MarinoSometimes you might want to know which part of the files each change
808008e37b6SJohn Marinofalls in.  If the files are source code, this could mean which function
809*6ea1f93eSDaniel Fojtwas changed.  If the files are documents, it could mean which chapter or
810*6ea1f93eSDaniel Fojtappendix was changed.  GNU 'diff' can show this by displaying the
811008e37b6SJohn Marinonearest section heading line that precedes the differing lines.  Which
812008e37b6SJohn Marinolines are "section headings" is determined by a regular expression.
813008e37b6SJohn Marino
814008e37b6SJohn Marino* Menu:
815008e37b6SJohn Marino
816008e37b6SJohn Marino* Specified Headings::  Showing headings that match regular expressions.
817008e37b6SJohn Marino* C Function Headings:: Showing headings of C functions.
818008e37b6SJohn Marino
819008e37b6SJohn Marino
820*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Specified Headings,  Next: C Function Headings,  Up: Sections
821008e37b6SJohn Marino
822008e37b6SJohn Marino2.2.3.1 Showing Lines That Match Regular Expressions
823008e37b6SJohn Marino....................................................
824008e37b6SJohn Marino
825008e37b6SJohn MarinoTo show in which sections differences occur for files that are not
826008e37b6SJohn Marinosource code for C or similar languages, use the
827*6ea1f93eSDaniel Fojt'--show-function-line=REGEXP' ('-F REGEXP') option.  'diff' considers
828*6ea1f93eSDaniel Fojtlines that match the 'grep'-style regular expression REGEXP to be the
829008e37b6SJohn Marinobeginning of a section of the file.  Here are suggested regular
830008e37b6SJohn Marinoexpressions for some common languages:
831008e37b6SJohn Marino
832*6ea1f93eSDaniel Fojt'^[[:alpha:]$_]'
833008e37b6SJohn Marino     C, C++, Prolog
834*6ea1f93eSDaniel Fojt'^('
835008e37b6SJohn Marino     Lisp
836*6ea1f93eSDaniel Fojt'^@node'
837008e37b6SJohn Marino     Texinfo
838008e37b6SJohn Marino
839008e37b6SJohn Marino   This option does not automatically select an output format; in order
840008e37b6SJohn Marinoto use it, you must select the context format (*note Context Format::)
841008e37b6SJohn Marinoor unified format (*note Unified Format::).  In other output formats it
842008e37b6SJohn Marinohas no effect.
843008e37b6SJohn Marino
844*6ea1f93eSDaniel Fojt   The '--show-function-line' ('-F') option finds the nearest unchanged
845008e37b6SJohn Marinoline that precedes each hunk of differences and matches the given
846008e37b6SJohn Marinoregular expression.  Then it adds that line to the end of the line of
847*6ea1f93eSDaniel Fojtasterisks in the context format, or to the '@@' line in unified format.
848008e37b6SJohn MarinoIf no matching line exists, this option leaves the output for that hunk
849008e37b6SJohn Marinounchanged.  If that line is more than 40 characters long, it outputs
850008e37b6SJohn Marinoonly the first 40 characters.  You can specify more than one regular
851*6ea1f93eSDaniel Fojtexpression for such lines; 'diff' tries to match each line against each
852008e37b6SJohn Marinoregular expression, starting with the last one given.  This means that
853*6ea1f93eSDaniel Fojtyou can use '-p' and '-F' together, if you wish.
854008e37b6SJohn Marino
855008e37b6SJohn Marino
856*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: C Function Headings,  Prev: Specified Headings,  Up: Sections
857008e37b6SJohn Marino
858008e37b6SJohn Marino2.2.3.2 Showing C Function Headings
859008e37b6SJohn Marino...................................
860008e37b6SJohn Marino
861008e37b6SJohn MarinoTo show in which functions differences occur for C and similar
862*6ea1f93eSDaniel Fojtlanguages, you can use the '--show-c-function' ('-p') option.  This
863008e37b6SJohn Marinooption automatically defaults to the context output format (*note
864*6ea1f93eSDaniel FojtContext Format::), with the default number of lines of context.  You can
865*6ea1f93eSDaniel Fojtoverride that number with '-C LINES' elsewhere in the command line.  You
866*6ea1f93eSDaniel Fojtcan override both the format and the number with '-U LINES' elsewhere in
867*6ea1f93eSDaniel Fojtthe command line.
868008e37b6SJohn Marino
869*6ea1f93eSDaniel Fojt   The '--show-c-function' ('-p') option is equivalent to '-F
870*6ea1f93eSDaniel Fojt'^[[:alpha:]$_]'' if the unified format is specified, otherwise '-c -F
871*6ea1f93eSDaniel Fojt'^[[:alpha:]$_]'' (*note Specified Headings::).  GNU 'diff' provides
872008e37b6SJohn Marinothis option for the sake of convenience.
873008e37b6SJohn Marino
874008e37b6SJohn Marino
875*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Alternate Names,  Prev: Sections,  Up: Context
876008e37b6SJohn Marino
877008e37b6SJohn Marino2.2.4 Showing Alternate File Names
878008e37b6SJohn Marino----------------------------------
879008e37b6SJohn Marino
880008e37b6SJohn MarinoIf you are comparing two files that have meaningless or uninformative
881*6ea1f93eSDaniel Fojtnames, you might want 'diff' to show alternate names in the header of
882008e37b6SJohn Marinothe context and unified output formats.  To do this, use the
883*6ea1f93eSDaniel Fojt'--label=LABEL' option.  The first time you give this option, its
884*6ea1f93eSDaniel Fojtargument replaces the name and date of the first file in the header; the
885*6ea1f93eSDaniel Fojtsecond time, its argument replaces the name and date of the second file.
886*6ea1f93eSDaniel FojtIf you give this option more than twice, 'diff' reports an error.  The
887*6ea1f93eSDaniel Fojt'--label' option does not affect the file names in the 'pr' header when
888*6ea1f93eSDaniel Fojtthe '-l' or '--paginate' option is used (*note Pagination::).
889008e37b6SJohn Marino
890*6ea1f93eSDaniel Fojt   Here are the first two lines of the output from 'diff -C 2
891008e37b6SJohn Marino--label=original --label=modified lao tzu':
892008e37b6SJohn Marino
893008e37b6SJohn Marino     *** original
894008e37b6SJohn Marino     --- modified
895008e37b6SJohn Marino
896008e37b6SJohn Marino
897*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Side by Side,  Next: Normal,  Prev: Context,  Up: Output Formats
898008e37b6SJohn Marino
899008e37b6SJohn Marino2.3 Showing Differences Side by Side
900008e37b6SJohn Marino====================================
901008e37b6SJohn Marino
902*6ea1f93eSDaniel Fojt'diff' can produce a side by side difference listing of two files.  The
903008e37b6SJohn Marinofiles are listed in two columns with a gutter between them.  The gutter
904008e37b6SJohn Marinocontains one of the following markers:
905008e37b6SJohn Marino
906008e37b6SJohn Marinowhite space
907008e37b6SJohn Marino     The corresponding lines are in common.  That is, either the lines
908008e37b6SJohn Marino     are identical, or the difference is ignored because of one of the
909*6ea1f93eSDaniel Fojt     '--ignore' options (*note White Space::).
910008e37b6SJohn Marino
911*6ea1f93eSDaniel Fojt'|'
912008e37b6SJohn Marino     The corresponding lines differ, and they are either both complete
913008e37b6SJohn Marino     or both incomplete.
914008e37b6SJohn Marino
915*6ea1f93eSDaniel Fojt'<'
916008e37b6SJohn Marino     The files differ and only the first file contains the line.
917008e37b6SJohn Marino
918*6ea1f93eSDaniel Fojt'>'
919008e37b6SJohn Marino     The files differ and only the second file contains the line.
920008e37b6SJohn Marino
921*6ea1f93eSDaniel Fojt'('
922008e37b6SJohn Marino     Only the first file contains the line, but the difference is
923008e37b6SJohn Marino     ignored.
924008e37b6SJohn Marino
925*6ea1f93eSDaniel Fojt')'
926008e37b6SJohn Marino     Only the second file contains the line, but the difference is
927008e37b6SJohn Marino     ignored.
928008e37b6SJohn Marino
929*6ea1f93eSDaniel Fojt'\'
930008e37b6SJohn Marino     The corresponding lines differ, and only the first line is
931008e37b6SJohn Marino     incomplete.
932008e37b6SJohn Marino
933*6ea1f93eSDaniel Fojt'/'
934008e37b6SJohn Marino     The corresponding lines differ, and only the second line is
935008e37b6SJohn Marino     incomplete.
936008e37b6SJohn Marino
937008e37b6SJohn Marino   Normally, an output line is incomplete if and only if the lines that
9384536c563SJohn Marinoit contains are incomplete.  *Note Incomplete Lines::.  However, when an
939008e37b6SJohn Marinooutput line represents two differing lines, one might be incomplete
940008e37b6SJohn Marinowhile the other is not.  In this case, the output line is complete, but
941*6ea1f93eSDaniel Fojtits the gutter is marked '\' if the first line is incomplete, '/' if the
942*6ea1f93eSDaniel Fojtsecond line is.
943008e37b6SJohn Marino
944008e37b6SJohn Marino   Side by side format is sometimes easiest to read, but it has
945008e37b6SJohn Marinolimitations.  It generates much wider output than usual, and truncates
946008e37b6SJohn Marinolines that are too long to fit.  Also, it relies on lining up output
947*6ea1f93eSDaniel Fojtmore heavily than usual, so its output looks particularly bad if you use
948*6ea1f93eSDaniel Fojtvarying width fonts, nonstandard tab stops, or nonprinting characters.
949008e37b6SJohn Marino
950*6ea1f93eSDaniel Fojt   You can use the 'sdiff' command to interactively merge side by side
951008e37b6SJohn Marinodifferences.  *Note Interactive Merging::, for more information on
952008e37b6SJohn Marinomerging files.
953008e37b6SJohn Marino
954008e37b6SJohn Marino* Menu:
955008e37b6SJohn Marino
956008e37b6SJohn Marino* Side by Side Format::  Controlling side by side output format.
957008e37b6SJohn Marino* Example Side by Side:: Sample side by side output.
958008e37b6SJohn Marino
959008e37b6SJohn Marino
960*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Side by Side Format,  Next: Example Side by Side,  Up: Side by Side
961008e37b6SJohn Marino
962008e37b6SJohn Marino2.3.1 Controlling Side by Side Format
963008e37b6SJohn Marino-------------------------------------
964008e37b6SJohn Marino
965*6ea1f93eSDaniel FojtThe '--side-by-side' ('-y') option selects side by side format.  Because
966*6ea1f93eSDaniel Fojtside by side output lines contain two input lines, the output is wider
967*6ea1f93eSDaniel Fojtthan usual: normally 130 print columns, which can fit onto a traditional
968*6ea1f93eSDaniel Fojtprinter line.  You can set the width of the output with the
969*6ea1f93eSDaniel Fojt'--width=COLUMNS' ('-W COLUMNS') option.  The output is split into two
970008e37b6SJohn Marinohalves of equal width, separated by a small gutter to mark differences;
971008e37b6SJohn Marinothe right half is aligned to a tab stop so that tabs line up.  Input
972008e37b6SJohn Marinolines that are too long to fit in half of an output line are truncated
973008e37b6SJohn Marinofor output.
974008e37b6SJohn Marino
975*6ea1f93eSDaniel Fojt   The '--left-column' option prints only the left column of two common
976*6ea1f93eSDaniel Fojtlines.  The '--suppress-common-lines' option suppresses common lines
977008e37b6SJohn Marinoentirely.
978008e37b6SJohn Marino
979008e37b6SJohn Marino
980*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example Side by Side,  Prev: Side by Side Format,  Up: Side by Side
981008e37b6SJohn Marino
982008e37b6SJohn Marino2.3.2 An Example of Side by Side Format
983008e37b6SJohn Marino---------------------------------------
984008e37b6SJohn Marino
985*6ea1f93eSDaniel FojtHere is the output of the command 'diff -y -W 72 lao tzu' (*note Sample
986008e37b6SJohn Marinodiff Input::, for the complete contents of the two files).
987008e37b6SJohn Marino
988008e37b6SJohn Marino     The Way that can be told of is n   <
989008e37b6SJohn Marino     The name that can be named is no   <
990008e37b6SJohn Marino     The Nameless is the origin of He        The Nameless is the origin of He
991008e37b6SJohn Marino     The Named is the mother of all t   |    The named is the mother of all t
992008e37b6SJohn Marino                                        >
993008e37b6SJohn Marino     Therefore let there always be no        Therefore let there always be no
994008e37b6SJohn Marino       so we may see their subtlety,           so we may see their subtlety,
995008e37b6SJohn Marino     And let there always be being,          And let there always be being,
996008e37b6SJohn Marino       so we may see their outcome.            so we may see their outcome.
997008e37b6SJohn Marino     The two are the same,                   The two are the same,
998008e37b6SJohn Marino     But after they are produced,            But after they are produced,
999008e37b6SJohn Marino       they have different names.              they have different names.
1000008e37b6SJohn Marino                                        >    They both may be called deep and
1001008e37b6SJohn Marino                                        >    Deeper and more profound,
1002008e37b6SJohn Marino                                        >    The door of all subtleties!
1003008e37b6SJohn Marino
1004008e37b6SJohn Marino
1005*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Normal,  Next: Scripts,  Prev: Side by Side,  Up: Output Formats
1006008e37b6SJohn Marino
1007008e37b6SJohn Marino2.4 Showing Differences Without Context
1008008e37b6SJohn Marino=======================================
1009008e37b6SJohn Marino
1010*6ea1f93eSDaniel FojtThe "normal" 'diff' output format shows each hunk of differences without
1011*6ea1f93eSDaniel Fojtany surrounding context.  Sometimes such output is the clearest way to
1012*6ea1f93eSDaniel Fojtsee how lines have changed, without the clutter of nearby unchanged
1013*6ea1f93eSDaniel Fojtlines (although you can get similar results with the context or unified
1014*6ea1f93eSDaniel Fojtformats by using 0 lines of context).  However, this format is no longer
1015*6ea1f93eSDaniel Fojtwidely used for sending out patches; for that purpose, the context
1016*6ea1f93eSDaniel Fojtformat (*note Context Format::) and the unified format (*note Unified
1017*6ea1f93eSDaniel FojtFormat::) are superior.  Normal format is the default for compatibility
1018*6ea1f93eSDaniel Fojtwith older versions of 'diff' and the POSIX standard.  Use the
1019*6ea1f93eSDaniel Fojt'--normal' option to select this output format explicitly.
1020008e37b6SJohn Marino
1021008e37b6SJohn Marino* Menu:
1022008e37b6SJohn Marino
1023008e37b6SJohn Marino* Example Normal::  Sample output in the normal format.
1024008e37b6SJohn Marino* Detailed Normal:: A detailed description of normal output format.
1025008e37b6SJohn Marino
1026008e37b6SJohn Marino
1027*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example Normal,  Next: Detailed Normal,  Up: Normal
1028008e37b6SJohn Marino
1029008e37b6SJohn Marino2.4.1 An Example of Normal Format
1030008e37b6SJohn Marino---------------------------------
1031008e37b6SJohn Marino
1032*6ea1f93eSDaniel FojtHere is the output of the command 'diff lao tzu' (*note Sample diff
1033008e37b6SJohn MarinoInput::, for the complete contents of the two files).  Notice that it
1034008e37b6SJohn Marinoshows only the lines that are different between the two files.
1035008e37b6SJohn Marino
1036008e37b6SJohn Marino     1,2d0
1037008e37b6SJohn Marino     < The Way that can be told of is not the eternal Way;
1038008e37b6SJohn Marino     < The name that can be named is not the eternal name.
1039008e37b6SJohn Marino     4c2,3
1040008e37b6SJohn Marino     < The Named is the mother of all things.
1041008e37b6SJohn Marino     ---
1042008e37b6SJohn Marino     > The named is the mother of all things.
1043008e37b6SJohn Marino     >
1044008e37b6SJohn Marino     11a11,13
1045008e37b6SJohn Marino     > They both may be called deep and profound.
1046008e37b6SJohn Marino     > Deeper and more profound,
1047008e37b6SJohn Marino     > The door of all subtleties!
1048008e37b6SJohn Marino
1049008e37b6SJohn Marino
1050*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Detailed Normal,  Prev: Example Normal,  Up: Normal
1051008e37b6SJohn Marino
1052008e37b6SJohn Marino2.4.2 Detailed Description of Normal Format
1053008e37b6SJohn Marino-------------------------------------------
1054008e37b6SJohn Marino
1055008e37b6SJohn MarinoThe normal output format consists of one or more hunks of differences;
1056008e37b6SJohn Marinoeach hunk shows one area where the files differ.  Normal format hunks
1057008e37b6SJohn Marinolook like this:
1058008e37b6SJohn Marino
1059008e37b6SJohn Marino     CHANGE-COMMAND
1060008e37b6SJohn Marino     < FROM-FILE-LINE
1061008e37b6SJohn Marino     < FROM-FILE-LINE...
1062008e37b6SJohn Marino     ---
1063008e37b6SJohn Marino     > TO-FILE-LINE
1064008e37b6SJohn Marino     > TO-FILE-LINE...
1065008e37b6SJohn Marino
1066008e37b6SJohn Marino   There are three types of change commands.  Each consists of a line
1067008e37b6SJohn Marinonumber or comma-separated range of lines in the first file, a single
1068008e37b6SJohn Marinocharacter indicating the kind of change to make, and a line number or
1069008e37b6SJohn Marinocomma-separated range of lines in the second file.  All line numbers are
1070008e37b6SJohn Marinothe original line numbers in each file.  The types of change commands
1071008e37b6SJohn Marinoare:
1072008e37b6SJohn Marino
1073*6ea1f93eSDaniel Fojt'LaR'
1074008e37b6SJohn Marino     Add the lines in range R of the second file after line L of the
1075*6ea1f93eSDaniel Fojt     first file.  For example, '8a12,15' means append lines 12-15 of
1076008e37b6SJohn Marino     file 2 after line 8 of file 1; or, if changing file 2 into file 1,
1077008e37b6SJohn Marino     delete lines 12-15 of file 2.
1078008e37b6SJohn Marino
1079*6ea1f93eSDaniel Fojt'FcT'
1080008e37b6SJohn Marino     Replace the lines in range F of the first file with lines in range
1081008e37b6SJohn Marino     T of the second file.  This is like a combined add and delete, but
1082*6ea1f93eSDaniel Fojt     more compact.  For example, '5,7c8,10' means change lines 5-7 of
1083008e37b6SJohn Marino     file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
1084008e37b6SJohn Marino     file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.
1085008e37b6SJohn Marino
1086*6ea1f93eSDaniel Fojt'RdL'
1087008e37b6SJohn Marino     Delete the lines in range R from the first file; line L is where
1088008e37b6SJohn Marino     they would have appeared in the second file had they not been
1089*6ea1f93eSDaniel Fojt     deleted.  For example, '5,7d3' means delete lines 5-7 of file 1;
1090008e37b6SJohn Marino     or, if changing file 2 into file 1, append lines 5-7 of file 1
1091008e37b6SJohn Marino     after line 3 of file 2.
1092008e37b6SJohn Marino
1093008e37b6SJohn Marino
1094*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Scripts,  Next: If-then-else,  Prev: Normal,  Up: Output Formats
1095008e37b6SJohn Marino
1096008e37b6SJohn Marino2.5 Making Edit Scripts
1097008e37b6SJohn Marino=======================
1098008e37b6SJohn Marino
1099008e37b6SJohn MarinoSeveral output modes produce command scripts for editing FROM-FILE to
1100008e37b6SJohn Marinoproduce TO-FILE.
1101008e37b6SJohn Marino
1102008e37b6SJohn Marino* Menu:
1103008e37b6SJohn Marino
1104*6ea1f93eSDaniel Fojt* ed Scripts:: Using 'diff' to produce commands for 'ed'.
1105*6ea1f93eSDaniel Fojt* Forward ed:: Making forward 'ed' scripts.
1106*6ea1f93eSDaniel Fojt* RCS::        A special 'diff' output format used by RCS.
1107008e37b6SJohn Marino
1108008e37b6SJohn Marino
1109*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: ed Scripts,  Next: Forward ed,  Up: Scripts
1110008e37b6SJohn Marino
1111*6ea1f93eSDaniel Fojt2.5.1 'ed' Scripts
1112008e37b6SJohn Marino------------------
1113008e37b6SJohn Marino
1114*6ea1f93eSDaniel Fojt'diff' can produce commands that direct the 'ed' text editor to change
1115*6ea1f93eSDaniel Fojtthe first file into the second file.  Long ago, this was the only output
1116*6ea1f93eSDaniel Fojtmode that was suitable for editing one file into another automatically;
1117*6ea1f93eSDaniel Fojttoday, with 'patch', it is almost obsolete.  Use the '--ed' ('-e')
1118*6ea1f93eSDaniel Fojtoption to select this output format.
1119008e37b6SJohn Marino
1120008e37b6SJohn Marino   Like the normal format (*note Normal::), this output format does not
1121008e37b6SJohn Marinoshow any context; unlike the normal format, it does not include the
1122008e37b6SJohn Marinoinformation necessary to apply the diff in reverse (to produce the first
1123008e37b6SJohn Marinofile if all you have is the second file and the diff).
1124008e37b6SJohn Marino
1125*6ea1f93eSDaniel Fojt   If the file 'd' contains the output of 'diff -e old new', then the
1126*6ea1f93eSDaniel Fojtcommand '(cat d && echo w) | ed - old' edits 'old' to make it a copy of
1127*6ea1f93eSDaniel Fojt'new'.  More generally, if 'd1', 'd2', ..., 'dN' contain the outputs of
1128*6ea1f93eSDaniel Fojt'diff -e old new1', 'diff -e new1 new2', ..., 'diff -e newN-1 newN',
1129*6ea1f93eSDaniel Fojtrespectively, then the command '(cat d1 d2 ... dN && echo w) | ed - old'
1130*6ea1f93eSDaniel Fojtedits 'old' to make it a copy of 'newN'.
1131008e37b6SJohn Marino
1132008e37b6SJohn Marino* Menu:
1133008e37b6SJohn Marino
1134*6ea1f93eSDaniel Fojt* Example ed::  A sample 'ed' script.
1135*6ea1f93eSDaniel Fojt* Detailed ed:: A detailed description of 'ed' format.
1136008e37b6SJohn Marino
1137008e37b6SJohn Marino
1138*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example ed,  Next: Detailed ed,  Up: ed Scripts
1139008e37b6SJohn Marino
1140*6ea1f93eSDaniel Fojt2.5.1.1 Example 'ed' Script
1141008e37b6SJohn Marino...........................
1142008e37b6SJohn Marino
1143*6ea1f93eSDaniel FojtHere is the output of 'diff -e lao tzu' (*note Sample diff Input::, for
1144008e37b6SJohn Marinothe complete contents of the two files):
1145008e37b6SJohn Marino
1146008e37b6SJohn Marino     11a
1147008e37b6SJohn Marino     They both may be called deep and profound.
1148008e37b6SJohn Marino     Deeper and more profound,
1149008e37b6SJohn Marino     The door of all subtleties!
1150008e37b6SJohn Marino     .
1151008e37b6SJohn Marino     4c
1152008e37b6SJohn Marino     The named is the mother of all things.
1153008e37b6SJohn Marino
1154008e37b6SJohn Marino     .
1155008e37b6SJohn Marino     1,2d
1156008e37b6SJohn Marino
1157008e37b6SJohn Marino
1158*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Detailed ed,  Prev: Example ed,  Up: ed Scripts
1159008e37b6SJohn Marino
1160*6ea1f93eSDaniel Fojt2.5.1.2 Detailed Description of 'ed' Format
1161008e37b6SJohn Marino...........................................
1162008e37b6SJohn Marino
1163*6ea1f93eSDaniel FojtThe 'ed' output format consists of one or more hunks of differences.
1164*6ea1f93eSDaniel FojtThe changes closest to the ends of the files come first so that commands
1165*6ea1f93eSDaniel Fojtthat change the number of lines do not affect how 'ed' interprets line
1166*6ea1f93eSDaniel Fojtnumbers in succeeding commands.  'ed' format hunks look like this:
1167008e37b6SJohn Marino
1168008e37b6SJohn Marino     CHANGE-COMMAND
1169008e37b6SJohn Marino     TO-FILE-LINE
1170008e37b6SJohn Marino     TO-FILE-LINE...
1171008e37b6SJohn Marino     .
1172008e37b6SJohn Marino
1173*6ea1f93eSDaniel Fojt   Because 'ed' uses a single period on a line to indicate the end of
1174*6ea1f93eSDaniel Fojtinput, GNU 'diff' protects lines of changes that contain a single period
1175*6ea1f93eSDaniel Fojton a line by writing two periods instead, then writing a subsequent 'ed'
1176*6ea1f93eSDaniel Fojtcommand to change the two periods into one.  The 'ed' format cannot
1177*6ea1f93eSDaniel Fojtrepresent an incomplete line, so if the second file ends in a changed
1178*6ea1f93eSDaniel Fojtincomplete line, 'diff' reports an error and then pretends that a
1179*6ea1f93eSDaniel Fojtnewline was appended.
1180008e37b6SJohn Marino
1181008e37b6SJohn Marino   There are three types of change commands.  Each consists of a line
1182008e37b6SJohn Marinonumber or comma-separated range of lines in the first file and a single
1183008e37b6SJohn Marinocharacter indicating the kind of change to make.  All line numbers are
1184008e37b6SJohn Marinothe original line numbers in the file.  The types of change commands
1185008e37b6SJohn Marinoare:
1186008e37b6SJohn Marino
1187*6ea1f93eSDaniel Fojt'La'
1188008e37b6SJohn Marino     Add text from the second file after line L in the first file.  For
1189*6ea1f93eSDaniel Fojt     example, '8a' means to add the following lines after line 8 of file
1190008e37b6SJohn Marino     1.
1191008e37b6SJohn Marino
1192*6ea1f93eSDaniel Fojt'Rc'
1193008e37b6SJohn Marino     Replace the lines in range R in the first file with the following
1194008e37b6SJohn Marino     lines.  Like a combined add and delete, but more compact.  For
1195*6ea1f93eSDaniel Fojt     example, '5,7c' means change lines 5-7 of file 1 to read as the
1196008e37b6SJohn Marino     text file 2.
1197008e37b6SJohn Marino
1198*6ea1f93eSDaniel Fojt'Rd'
1199008e37b6SJohn Marino     Delete the lines in range R from the first file.  For example,
1200*6ea1f93eSDaniel Fojt     '5,7d' means delete lines 5-7 of file 1.
1201008e37b6SJohn Marino
1202008e37b6SJohn Marino
1203*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Forward ed,  Next: RCS,  Prev: ed Scripts,  Up: Scripts
1204008e37b6SJohn Marino
1205*6ea1f93eSDaniel Fojt2.5.2 Forward 'ed' Scripts
1206008e37b6SJohn Marino--------------------------
1207008e37b6SJohn Marino
1208*6ea1f93eSDaniel Fojt'diff' can produce output that is like an 'ed' script, but with hunks in
1209*6ea1f93eSDaniel Fojtforward (front to back) order.  The format of the commands is also
1210008e37b6SJohn Marinochanged slightly: command characters precede the lines they modify,
1211008e37b6SJohn Marinospaces separate line numbers in ranges, and no attempt is made to
1212*6ea1f93eSDaniel Fojtdisambiguate hunk lines consisting of a single period.  Like 'ed'
1213*6ea1f93eSDaniel Fojtformat, forward 'ed' format cannot represent incomplete lines.
1214008e37b6SJohn Marino
1215*6ea1f93eSDaniel Fojt   Forward 'ed' format is not very useful, because neither 'ed' nor
1216*6ea1f93eSDaniel Fojt'patch' can apply diffs in this format.  It exists mainly for
1217*6ea1f93eSDaniel Fojtcompatibility with older versions of 'diff'.  Use the '-f' or
1218*6ea1f93eSDaniel Fojt'--forward-ed' option to select it.
1219008e37b6SJohn Marino
1220008e37b6SJohn Marino
1221*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: RCS,  Prev: Forward ed,  Up: Scripts
1222008e37b6SJohn Marino
1223008e37b6SJohn Marino2.5.3 RCS Scripts
1224008e37b6SJohn Marino-----------------
1225008e37b6SJohn Marino
1226008e37b6SJohn MarinoThe RCS output format is designed specifically for use by the Revision
1227008e37b6SJohn MarinoControl System, which is a set of free programs used for organizing
1228*6ea1f93eSDaniel Fojtdifferent versions and systems of files.  Use the '--rcs' ('-n') option
1229*6ea1f93eSDaniel Fojtto select this output format.  It is like the forward 'ed' format (*note
1230*6ea1f93eSDaniel FojtForward ed::), but it can represent arbitrary changes to the contents of
1231*6ea1f93eSDaniel Fojta file because it avoids the forward 'ed' format's problems with lines
1232*6ea1f93eSDaniel Fojtconsisting of a single period and with incomplete lines.  Instead of
1233*6ea1f93eSDaniel Fojtending text sections with a line consisting of a single period, each
1234*6ea1f93eSDaniel Fojtcommand specifies the number of lines it affects; a combination of the
1235*6ea1f93eSDaniel Fojt'a' and 'd' commands are used instead of 'c'.  Also, if the second file
1236*6ea1f93eSDaniel Fojtends in a changed incomplete line, then the output also ends in an
1237*6ea1f93eSDaniel Fojtincomplete line.
1238008e37b6SJohn Marino
1239*6ea1f93eSDaniel Fojt   Here is the output of 'diff -n lao tzu' (*note Sample diff Input::,
1240008e37b6SJohn Marinofor the complete contents of the two files):
1241008e37b6SJohn Marino
1242008e37b6SJohn Marino     d1 2
1243008e37b6SJohn Marino     d4 1
1244008e37b6SJohn Marino     a4 2
1245008e37b6SJohn Marino     The named is the mother of all things.
1246008e37b6SJohn Marino
1247008e37b6SJohn Marino     a11 3
1248008e37b6SJohn Marino     They both may be called deep and profound.
1249008e37b6SJohn Marino     Deeper and more profound,
1250008e37b6SJohn Marino     The door of all subtleties!
1251008e37b6SJohn Marino
1252008e37b6SJohn Marino
1253*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: If-then-else,  Prev: Scripts,  Up: Output Formats
1254008e37b6SJohn Marino
1255008e37b6SJohn Marino2.6 Merging Files with If-then-else
1256008e37b6SJohn Marino===================================
1257008e37b6SJohn Marino
1258*6ea1f93eSDaniel FojtYou can use 'diff' to merge two files of C source code.  The output of
1259*6ea1f93eSDaniel Fojt'diff' in this format contains all the lines of both files.  Lines
1260008e37b6SJohn Marinocommon to both files are output just once; the differing parts are
1261*6ea1f93eSDaniel Fojtseparated by the C preprocessor directives '#ifdef NAME' or '#ifndef
1262*6ea1f93eSDaniel FojtNAME', '#else', and '#endif'.  When compiling the output, you select
1263008e37b6SJohn Marinowhich version to use by either defining or leaving undefined the macro
1264008e37b6SJohn MarinoNAME.
1265008e37b6SJohn Marino
1266*6ea1f93eSDaniel Fojt   To merge two files, use 'diff' with the '-D NAME' or '--ifdef=NAME'
1267008e37b6SJohn Marinooption.  The argument NAME is the C preprocessor identifier to use in
1268*6ea1f93eSDaniel Fojtthe '#ifdef' and '#ifndef' directives.
1269008e37b6SJohn Marino
1270*6ea1f93eSDaniel Fojt   For example, if you change an instance of 'wait (&s)' to 'waitpid
1271008e37b6SJohn Marino(-1, &s, 0)' and then merge the old and new files with the
1272*6ea1f93eSDaniel Fojt'--ifdef=HAVE_WAITPID' option, then the affected part of your code might
1273*6ea1f93eSDaniel Fojtlook like this:
1274008e37b6SJohn Marino
1275008e37b6SJohn Marino         do {
1276008e37b6SJohn Marino     #ifndef HAVE_WAITPID
1277008e37b6SJohn Marino             if ((w = wait (&s)) < 0  &&  errno != EINTR)
1278008e37b6SJohn Marino     #else /* HAVE_WAITPID */
1279008e37b6SJohn Marino             if ((w = waitpid (-1, &s, 0)) < 0  &&  errno != EINTR)
1280008e37b6SJohn Marino     #endif /* HAVE_WAITPID */
1281008e37b6SJohn Marino                 return w;
1282008e37b6SJohn Marino         } while (w != child);
1283008e37b6SJohn Marino
1284008e37b6SJohn Marino   You can specify formats for languages other than C by using line
1285008e37b6SJohn Marinogroup formats and line formats, as described in the next sections.
1286008e37b6SJohn Marino
1287008e37b6SJohn Marino* Menu:
1288008e37b6SJohn Marino
1289008e37b6SJohn Marino* Line Group Formats::    Formats for general if-then-else line groups.
1290008e37b6SJohn Marino* Line Formats::          Formats for each line in a line group.
1291008e37b6SJohn Marino* Example If-then-else::  Sample if-then-else format output.
1292008e37b6SJohn Marino* Detailed If-then-else:: A detailed description of if-then-else format.
1293008e37b6SJohn Marino
1294008e37b6SJohn Marino
1295*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Line Group Formats,  Next: Line Formats,  Up: If-then-else
1296008e37b6SJohn Marino
1297008e37b6SJohn Marino2.6.1 Line Group Formats
1298008e37b6SJohn Marino------------------------
1299008e37b6SJohn Marino
1300008e37b6SJohn MarinoLine group formats let you specify formats suitable for many
1301008e37b6SJohn Marinoapplications that allow if-then-else input, including programming
1302008e37b6SJohn Marinolanguages and text formatting languages.  A line group format specifies
1303008e37b6SJohn Marinothe output format for a contiguous group of similar lines.
1304008e37b6SJohn Marino
1305*6ea1f93eSDaniel Fojt   For example, the following command compares the TeX files 'old' and
1306*6ea1f93eSDaniel Fojt'new', and outputs a merged file in which old regions are surrounded by
1307*6ea1f93eSDaniel Fojt'\begin{em}'-'\end{em}' lines, and new regions are surrounded by
1308*6ea1f93eSDaniel Fojt'\begin{bf}'-'\end{bf}' lines.
1309008e37b6SJohn Marino
1310008e37b6SJohn Marino     diff \
1311008e37b6SJohn Marino        --old-group-format='\begin{em}
1312008e37b6SJohn Marino     %<\end{em}
1313008e37b6SJohn Marino     ' \
1314008e37b6SJohn Marino        --new-group-format='\begin{bf}
1315008e37b6SJohn Marino     %>\end{bf}
1316008e37b6SJohn Marino     ' \
1317008e37b6SJohn Marino        old new
1318008e37b6SJohn Marino
1319008e37b6SJohn Marino   The following command is equivalent to the above example, but it is a
1320008e37b6SJohn Marinolittle more verbose, because it spells out the default line group
1321008e37b6SJohn Marinoformats.
1322008e37b6SJohn Marino
1323008e37b6SJohn Marino     diff \
1324008e37b6SJohn Marino        --old-group-format='\begin{em}
1325008e37b6SJohn Marino     %<\end{em}
1326008e37b6SJohn Marino     ' \
1327008e37b6SJohn Marino        --new-group-format='\begin{bf}
1328008e37b6SJohn Marino     %>\end{bf}
1329008e37b6SJohn Marino     ' \
1330008e37b6SJohn Marino        --unchanged-group-format='%=' \
1331008e37b6SJohn Marino        --changed-group-format='\begin{em}
1332008e37b6SJohn Marino     %<\end{em}
1333008e37b6SJohn Marino     \begin{bf}
1334008e37b6SJohn Marino     %>\end{bf}
1335008e37b6SJohn Marino     ' \
1336008e37b6SJohn Marino        old new
1337008e37b6SJohn Marino
1338008e37b6SJohn Marino   Here is a more advanced example, which outputs a diff listing with
1339008e37b6SJohn Marinoheaders containing line numbers in a "plain English" style.
1340008e37b6SJohn Marino
1341008e37b6SJohn Marino     diff \
1342008e37b6SJohn Marino        --unchanged-group-format='' \
1343008e37b6SJohn Marino        --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
1344008e37b6SJohn Marino     %<' \
1345008e37b6SJohn Marino        --new-group-format='-------- %dN line%(N=1?:s) added after %de:
1346008e37b6SJohn Marino     %>' \
1347008e37b6SJohn Marino        --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
1348008e37b6SJohn Marino     %<-------- to:
1349008e37b6SJohn Marino     %>' \
1350008e37b6SJohn Marino        old new
1351008e37b6SJohn Marino
1352*6ea1f93eSDaniel Fojt   To specify a line group format, use 'diff' with one of the options
1353008e37b6SJohn Marinolisted below.  You can specify up to four line group formats, one for
1354008e37b6SJohn Marinoeach kind of line group.  You should quote FORMAT, because it typically
1355008e37b6SJohn Marinocontains shell metacharacters.
1356008e37b6SJohn Marino
1357*6ea1f93eSDaniel Fojt'--old-group-format=FORMAT'
1358008e37b6SJohn Marino     These line groups are hunks containing only lines from the first
1359008e37b6SJohn Marino     file.  The default old group format is the same as the changed
1360008e37b6SJohn Marino     group format if it is specified; otherwise it is a format that
1361008e37b6SJohn Marino     outputs the line group as-is.
1362008e37b6SJohn Marino
1363*6ea1f93eSDaniel Fojt'--new-group-format=FORMAT'
1364008e37b6SJohn Marino     These line groups are hunks containing only lines from the second
1365008e37b6SJohn Marino     file.  The default new group format is same as the changed group
1366008e37b6SJohn Marino     format if it is specified; otherwise it is a format that outputs
1367008e37b6SJohn Marino     the line group as-is.
1368008e37b6SJohn Marino
1369*6ea1f93eSDaniel Fojt'--changed-group-format=FORMAT'
1370008e37b6SJohn Marino     These line groups are hunks containing lines from both files.  The
1371008e37b6SJohn Marino     default changed group format is the concatenation of the old and
1372008e37b6SJohn Marino     new group formats.
1373008e37b6SJohn Marino
1374*6ea1f93eSDaniel Fojt'--unchanged-group-format=FORMAT'
1375008e37b6SJohn Marino     These line groups contain lines common to both files.  The default
1376008e37b6SJohn Marino     unchanged group format is a format that outputs the line group
1377008e37b6SJohn Marino     as-is.
1378008e37b6SJohn Marino
1379008e37b6SJohn Marino   In a line group format, ordinary characters represent themselves;
1380*6ea1f93eSDaniel Fojtconversion specifications start with '%' and have one of the following
1381008e37b6SJohn Marinoforms.
1382008e37b6SJohn Marino
1383*6ea1f93eSDaniel Fojt'%<'
1384008e37b6SJohn Marino     stands for the lines from the first file, including the trailing
1385008e37b6SJohn Marino     newline.  Each line is formatted according to the old line format
1386008e37b6SJohn Marino     (*note Line Formats::).
1387008e37b6SJohn Marino
1388*6ea1f93eSDaniel Fojt'%>'
1389008e37b6SJohn Marino     stands for the lines from the second file, including the trailing
1390008e37b6SJohn Marino     newline.  Each line is formatted according to the new line format.
1391008e37b6SJohn Marino
1392*6ea1f93eSDaniel Fojt'%='
1393008e37b6SJohn Marino     stands for the lines common to both files, including the trailing
1394008e37b6SJohn Marino     newline.  Each line is formatted according to the unchanged line
1395008e37b6SJohn Marino     format.
1396008e37b6SJohn Marino
1397*6ea1f93eSDaniel Fojt'%%'
1398*6ea1f93eSDaniel Fojt     stands for '%'.
1399008e37b6SJohn Marino
1400*6ea1f93eSDaniel Fojt'%c'C''
1401008e37b6SJohn Marino     where C is a single character, stands for C.  C may not be a
1402*6ea1f93eSDaniel Fojt     backslash or an apostrophe.  For example, '%c':'' stands for a
1403*6ea1f93eSDaniel Fojt     colon, even inside the then-part of an if-then-else format, which a
1404*6ea1f93eSDaniel Fojt     colon would normally terminate.
1405008e37b6SJohn Marino
1406*6ea1f93eSDaniel Fojt'%c'\O''
1407008e37b6SJohn Marino     where O is a string of 1, 2, or 3 octal digits, stands for the
1408*6ea1f93eSDaniel Fojt     character with octal code O.  For example, '%c'\0'' stands for a
1409008e37b6SJohn Marino     null character.
1410008e37b6SJohn Marino
1411*6ea1f93eSDaniel Fojt'FN'
1412*6ea1f93eSDaniel Fojt     where F is a 'printf' conversion specification and N is one of the
1413008e37b6SJohn Marino     following letters, stands for N's value formatted with F.
1414008e37b6SJohn Marino
1415*6ea1f93eSDaniel Fojt     'e'
1416008e37b6SJohn Marino          The line number of the line just before the group in the old
1417008e37b6SJohn Marino          file.
1418008e37b6SJohn Marino
1419*6ea1f93eSDaniel Fojt     'f'
1420008e37b6SJohn Marino          The line number of the first line in the group in the old
1421008e37b6SJohn Marino          file; equals E + 1.
1422008e37b6SJohn Marino
1423*6ea1f93eSDaniel Fojt     'l'
1424008e37b6SJohn Marino          The line number of the last line in the group in the old file.
1425008e37b6SJohn Marino
1426*6ea1f93eSDaniel Fojt     'm'
1427008e37b6SJohn Marino          The line number of the line just after the group in the old
1428008e37b6SJohn Marino          file; equals L + 1.
1429008e37b6SJohn Marino
1430*6ea1f93eSDaniel Fojt     'n'
1431*6ea1f93eSDaniel Fojt          The number of lines in the group in the old file; equals L - F
1432*6ea1f93eSDaniel Fojt          + 1.
1433008e37b6SJohn Marino
1434*6ea1f93eSDaniel Fojt     'E, F, L, M, N'
1435008e37b6SJohn Marino          Likewise, for lines in the new file.
1436008e37b6SJohn Marino
1437*6ea1f93eSDaniel Fojt     The 'printf' conversion specification can be '%d', '%o', '%x', or
1438*6ea1f93eSDaniel Fojt     '%X', specifying decimal, octal, lower case hexadecimal, or upper
1439*6ea1f93eSDaniel Fojt     case hexadecimal output respectively.  After the '%' the following
1440008e37b6SJohn Marino     options can appear in sequence: a series of zero or more flags; an
1441008e37b6SJohn Marino     integer specifying the minimum field width; and a period followed
1442008e37b6SJohn Marino     by an optional integer specifying the minimum number of digits.
1443*6ea1f93eSDaniel Fojt     The flags are '-' for left-justification, ''' for separating the
1444*6ea1f93eSDaniel Fojt     digit into groups as specified by the 'LC_NUMERIC' locale category,
1445*6ea1f93eSDaniel Fojt     and '0' for padding with zeros instead of spaces.  For example,
1446*6ea1f93eSDaniel Fojt     '%5dN' prints the number of new lines in the group in a field of
1447*6ea1f93eSDaniel Fojt     width 5 characters, using the 'printf' format '"%5d"'.
1448008e37b6SJohn Marino
1449*6ea1f93eSDaniel Fojt'(A=B?T:E)'
1450008e37b6SJohn Marino     If A equals B then T else E.  A and B are each either a decimal
1451*6ea1f93eSDaniel Fojt     constant or a single letter interpreted as above.  This format spec
1452*6ea1f93eSDaniel Fojt     is equivalent to T if A's value equals B's; otherwise it is
1453008e37b6SJohn Marino     equivalent to E.
1454008e37b6SJohn Marino
1455*6ea1f93eSDaniel Fojt     For example, '%(N=0?no:%dN) line%(N=1?:s)' is equivalent to 'no
1456008e37b6SJohn Marino     lines' if N (the number of lines in the group in the new file) is
1457*6ea1f93eSDaniel Fojt     0, to '1 line' if N is 1, and to '%dN lines' otherwise.
1458008e37b6SJohn Marino
1459008e37b6SJohn Marino
1460*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Line Formats,  Next: Example If-then-else,  Prev: Line Group Formats,  Up: If-then-else
1461008e37b6SJohn Marino
1462008e37b6SJohn Marino2.6.2 Line Formats
1463008e37b6SJohn Marino------------------
1464008e37b6SJohn Marino
1465*6ea1f93eSDaniel FojtLine formats control how each line taken from an input file is output as
1466*6ea1f93eSDaniel Fojtpart of a line group in if-then-else format.
1467008e37b6SJohn Marino
1468008e37b6SJohn Marino   For example, the following command outputs text with a one-character
1469008e37b6SJohn Marinochange indicator to the left of the text.  The first character of output
1470*6ea1f93eSDaniel Fojtis '-' for deleted lines, '|' for added lines, and a space for unchanged
1471*6ea1f93eSDaniel Fojtlines.  The formats contain newline characters where newlines are
1472*6ea1f93eSDaniel Fojtdesired on output.
1473008e37b6SJohn Marino
1474008e37b6SJohn Marino     diff \
1475008e37b6SJohn Marino        --old-line-format='-%l
1476008e37b6SJohn Marino     ' \
1477008e37b6SJohn Marino        --new-line-format='|%l
1478008e37b6SJohn Marino     ' \
1479008e37b6SJohn Marino        --unchanged-line-format=' %l
1480008e37b6SJohn Marino     ' \
1481008e37b6SJohn Marino        old new
1482008e37b6SJohn Marino
1483008e37b6SJohn Marino   To specify a line format, use one of the following options.  You
1484008e37b6SJohn Marinoshould quote FORMAT, since it often contains shell metacharacters.
1485008e37b6SJohn Marino
1486*6ea1f93eSDaniel Fojt'--old-line-format=FORMAT'
1487008e37b6SJohn Marino     formats lines just from the first file.
1488008e37b6SJohn Marino
1489*6ea1f93eSDaniel Fojt'--new-line-format=FORMAT'
1490008e37b6SJohn Marino     formats lines just from the second file.
1491008e37b6SJohn Marino
1492*6ea1f93eSDaniel Fojt'--unchanged-line-format=FORMAT'
1493008e37b6SJohn Marino     formats lines common to both files.
1494008e37b6SJohn Marino
1495*6ea1f93eSDaniel Fojt'--line-format=FORMAT'
1496008e37b6SJohn Marino     formats all lines; in effect, it sets all three above options
1497008e37b6SJohn Marino     simultaneously.
1498008e37b6SJohn Marino
1499008e37b6SJohn Marino   In a line format, ordinary characters represent themselves;
1500*6ea1f93eSDaniel Fojtconversion specifications start with '%' and have one of the following
1501008e37b6SJohn Marinoforms.
1502008e37b6SJohn Marino
1503*6ea1f93eSDaniel Fojt'%l'
1504008e37b6SJohn Marino     stands for the contents of the line, not counting its trailing
1505008e37b6SJohn Marino     newline (if any).  This format ignores whether the line is
1506008e37b6SJohn Marino     incomplete; *Note Incomplete Lines::.
1507008e37b6SJohn Marino
1508*6ea1f93eSDaniel Fojt'%L'
1509008e37b6SJohn Marino     stands for the contents of the line, including its trailing newline
1510008e37b6SJohn Marino     (if any).  If a line is incomplete, this format preserves its
1511008e37b6SJohn Marino     incompleteness.
1512008e37b6SJohn Marino
1513*6ea1f93eSDaniel Fojt'%%'
1514*6ea1f93eSDaniel Fojt     stands for '%'.
1515008e37b6SJohn Marino
1516*6ea1f93eSDaniel Fojt'%c'C''
1517008e37b6SJohn Marino     where C is a single character, stands for C.  C may not be a
1518*6ea1f93eSDaniel Fojt     backslash or an apostrophe.  For example, '%c':'' stands for a
1519008e37b6SJohn Marino     colon.
1520008e37b6SJohn Marino
1521*6ea1f93eSDaniel Fojt'%c'\O''
1522008e37b6SJohn Marino     where O is a string of 1, 2, or 3 octal digits, stands for the
1523*6ea1f93eSDaniel Fojt     character with octal code O.  For example, '%c'\0'' stands for a
1524008e37b6SJohn Marino     null character.
1525008e37b6SJohn Marino
1526*6ea1f93eSDaniel Fojt'Fn'
1527*6ea1f93eSDaniel Fojt     where F is a 'printf' conversion specification, stands for the line
1528*6ea1f93eSDaniel Fojt     number formatted with F.  For example, '%.5dn' prints the line
1529*6ea1f93eSDaniel Fojt     number using the 'printf' format '"%.5d"'.  *Note Line Group
1530008e37b6SJohn Marino     Formats::, for more about printf conversion specifications.
1531008e37b6SJohn Marino
1532*6ea1f93eSDaniel Fojt   The default line format is '%l' followed by a newline character.
1533008e37b6SJohn Marino
1534008e37b6SJohn Marino   If the input contains tab characters and it is important that they
1535*6ea1f93eSDaniel Fojtline up on output, you should ensure that '%l' or '%L' in a line format
1536*6ea1f93eSDaniel Fojtis just after a tab stop (e.g. by preceding '%l' or '%L' with a tab
1537*6ea1f93eSDaniel Fojtcharacter), or you should use the '-t' or '--expand-tabs' option.
1538008e37b6SJohn Marino
1539008e37b6SJohn Marino   Taken together, the line and line group formats let you specify many
1540008e37b6SJohn Marinodifferent formats.  For example, the following command uses a format
1541*6ea1f93eSDaniel Fojtsimilar to normal 'diff' format.  You can tailor this command to get
1542*6ea1f93eSDaniel Fojtfine control over 'diff' output.
1543008e37b6SJohn Marino
1544008e37b6SJohn Marino     diff \
1545008e37b6SJohn Marino        --old-line-format='< %l
1546008e37b6SJohn Marino     ' \
1547008e37b6SJohn Marino        --new-line-format='> %l
1548008e37b6SJohn Marino     ' \
1549008e37b6SJohn Marino        --old-group-format='%df%(f=l?:,%dl)d%dE
1550008e37b6SJohn Marino     %<' \
1551008e37b6SJohn Marino        --new-group-format='%dea%dF%(F=L?:,%dL)
1552008e37b6SJohn Marino     %>' \
1553008e37b6SJohn Marino        --changed-group-format='%df%(f=l?:,%dl)c%dF%(F=L?:,%dL)
1554008e37b6SJohn Marino     %<---
1555008e37b6SJohn Marino     %>' \
1556008e37b6SJohn Marino        --unchanged-group-format='' \
1557008e37b6SJohn Marino        old new
1558008e37b6SJohn Marino
1559008e37b6SJohn Marino
1560*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example If-then-else,  Next: Detailed If-then-else,  Prev: Line Formats,  Up: If-then-else
1561008e37b6SJohn Marino
1562008e37b6SJohn Marino2.6.3 An Example of If-then-else Format
1563008e37b6SJohn Marino---------------------------------------
1564008e37b6SJohn Marino
1565*6ea1f93eSDaniel FojtHere is the output of 'diff -DTWO lao tzu' (*note Sample diff Input::,
1566008e37b6SJohn Marinofor the complete contents of the two files):
1567008e37b6SJohn Marino
1568008e37b6SJohn Marino     #ifndef TWO
1569008e37b6SJohn Marino     The Way that can be told of is not the eternal Way;
1570008e37b6SJohn Marino     The name that can be named is not the eternal name.
1571008e37b6SJohn Marino     #endif /* ! TWO */
1572008e37b6SJohn Marino     The Nameless is the origin of Heaven and Earth;
1573008e37b6SJohn Marino     #ifndef TWO
1574008e37b6SJohn Marino     The Named is the mother of all things.
1575008e37b6SJohn Marino     #else /* TWO */
1576008e37b6SJohn Marino     The named is the mother of all things.
1577008e37b6SJohn Marino
1578008e37b6SJohn Marino     #endif /* TWO */
1579008e37b6SJohn Marino     Therefore let there always be non-being,
1580008e37b6SJohn Marino       so we may see their subtlety,
1581008e37b6SJohn Marino     And let there always be being,
1582008e37b6SJohn Marino       so we may see their outcome.
1583008e37b6SJohn Marino     The two are the same,
1584008e37b6SJohn Marino     But after they are produced,
1585008e37b6SJohn Marino       they have different names.
1586008e37b6SJohn Marino     #ifdef TWO
1587008e37b6SJohn Marino     They both may be called deep and profound.
1588008e37b6SJohn Marino     Deeper and more profound,
1589008e37b6SJohn Marino     The door of all subtleties!
1590008e37b6SJohn Marino     #endif /* TWO */
1591008e37b6SJohn Marino
1592008e37b6SJohn Marino
1593*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Detailed If-then-else,  Prev: Example If-then-else,  Up: If-then-else
1594008e37b6SJohn Marino
1595008e37b6SJohn Marino2.6.4 Detailed Description of If-then-else Format
1596008e37b6SJohn Marino-------------------------------------------------
1597008e37b6SJohn Marino
1598*6ea1f93eSDaniel FojtFor lines common to both files, 'diff' uses the unchanged line group
1599008e37b6SJohn Marinoformat.  For each hunk of differences in the merged output format, if
1600*6ea1f93eSDaniel Fojtthe hunk contains only lines from the first file, 'diff' uses the old
1601*6ea1f93eSDaniel Fojtline group format; if the hunk contains only lines from the second file,
1602*6ea1f93eSDaniel Fojt'diff' uses the new group format; otherwise, 'diff' uses the changed
1603*6ea1f93eSDaniel Fojtgroup format.
1604008e37b6SJohn Marino
1605008e37b6SJohn Marino   The old, new, and unchanged line formats specify the output format of
1606008e37b6SJohn Marinolines from the first file, lines from the second file, and lines common
1607008e37b6SJohn Marinoto both files, respectively.
1608008e37b6SJohn Marino
1609*6ea1f93eSDaniel Fojt   The option '--ifdef=NAME' is equivalent to the following sequence of
1610008e37b6SJohn Marinooptions using shell syntax:
1611008e37b6SJohn Marino
1612008e37b6SJohn Marino     --old-group-format='#ifndef NAME
1613008e37b6SJohn Marino     %<#endif /* ! NAME */
1614008e37b6SJohn Marino     ' \
1615008e37b6SJohn Marino     --new-group-format='#ifdef NAME
1616008e37b6SJohn Marino     %>#endif /* NAME */
1617008e37b6SJohn Marino     ' \
1618008e37b6SJohn Marino     --unchanged-group-format='%=' \
1619008e37b6SJohn Marino     --changed-group-format='#ifndef NAME
1620008e37b6SJohn Marino     %<#else /* NAME */
1621008e37b6SJohn Marino     %>#endif /* NAME */
1622008e37b6SJohn Marino     '
1623008e37b6SJohn Marino
1624*6ea1f93eSDaniel Fojt   You should carefully check the 'diff' output for proper nesting.  For
1625*6ea1f93eSDaniel Fojtexample, when using the '-D NAME' or '--ifdef=NAME' option, you should
1626*6ea1f93eSDaniel Fojtcheck that if the differing lines contain any of the C preprocessor
1627*6ea1f93eSDaniel Fojtdirectives '#ifdef', '#ifndef', '#else', '#elif', or '#endif', they are
1628*6ea1f93eSDaniel Fojtnested properly and match.  If they don't, you must make corrections
1629*6ea1f93eSDaniel Fojtmanually.  It is a good idea to carefully check the resulting code
1630*6ea1f93eSDaniel Fojtanyway to make sure that it really does what you want it to; depending
1631*6ea1f93eSDaniel Fojton how the input files were produced, the output might contain duplicate
1632*6ea1f93eSDaniel Fojtor otherwise incorrect code.
1633008e37b6SJohn Marino
1634*6ea1f93eSDaniel Fojt   The 'patch' '-D NAME' option behaves like the 'diff' '-D NAME'
1635008e37b6SJohn Marinooption, except it operates on a file and a diff to produce a merged
16364536c563SJohn Marinofile.  *Note patch Options::.
1637008e37b6SJohn Marino
1638008e37b6SJohn Marino
1639*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Incomplete Lines,  Next: Comparing Directories,  Prev: Output Formats,  Up: Top
1640008e37b6SJohn Marino
1641008e37b6SJohn Marino3 Incomplete Lines
1642008e37b6SJohn Marino******************
1643008e37b6SJohn Marino
1644008e37b6SJohn MarinoWhen an input file ends in a non-newline character, its last line is
1645*6ea1f93eSDaniel Fojtcalled an "incomplete line" because its last character is not a newline.
1646*6ea1f93eSDaniel FojtAll other lines are called "full lines" and end in a newline character.
1647*6ea1f93eSDaniel FojtIncomplete lines do not match full lines unless differences in white
1648*6ea1f93eSDaniel Fojtspace are ignored (*note White Space::).
1649008e37b6SJohn Marino
1650008e37b6SJohn Marino   An incomplete line is normally distinguished on output from a full
1651*6ea1f93eSDaniel Fojtline by a following line that starts with '\'.  However, the RCS format
1652008e37b6SJohn Marino(*note RCS::) outputs the incomplete line as-is, without any trailing
1653008e37b6SJohn Marinonewline or following line.  The side by side format normally represents
1654*6ea1f93eSDaniel Fojtincomplete lines as-is, but in some cases uses a '\' or '/' gutter
1655*6ea1f93eSDaniel Fojtmarker.  *Note Side by Side::.  The if-then-else line format preserves a
1656*6ea1f93eSDaniel Fojtline's incompleteness with '%L', and discards the newline with '%l'.
1657*6ea1f93eSDaniel Fojt*Note Line Formats::.  Finally, with the 'ed' and forward 'ed' output
1658*6ea1f93eSDaniel Fojtformats (*note Output Formats::) 'diff' cannot represent an incomplete
1659008e37b6SJohn Marinoline, so it pretends there was a newline and reports an error.
1660008e37b6SJohn Marino
1661*6ea1f93eSDaniel Fojt   For example, suppose 'F' and 'G' are one-byte files that contain just
1662*6ea1f93eSDaniel Fojt'f' and 'g', respectively.  Then 'diff F G' outputs
1663008e37b6SJohn Marino
1664008e37b6SJohn Marino     1c1
1665008e37b6SJohn Marino     < f
1666008e37b6SJohn Marino     \ No newline at end of file
1667008e37b6SJohn Marino     ---
1668008e37b6SJohn Marino     > g
1669008e37b6SJohn Marino     \ No newline at end of file
1670008e37b6SJohn Marino
1671*6ea1f93eSDaniel Fojt(The exact message may differ in non-English locales.)  'diff -n F G'
1672008e37b6SJohn Marinooutputs the following without a trailing newline:
1673008e37b6SJohn Marino
1674008e37b6SJohn Marino     d1 1
1675008e37b6SJohn Marino     a1 1
1676008e37b6SJohn Marino     g
1677008e37b6SJohn Marino
1678*6ea1f93eSDaniel Fojt'diff -e F G' reports two errors and outputs the following:
1679008e37b6SJohn Marino
1680008e37b6SJohn Marino     1c
1681008e37b6SJohn Marino     g
1682008e37b6SJohn Marino     .
1683008e37b6SJohn Marino
1684008e37b6SJohn Marino
1685*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Comparing Directories,  Next: Adjusting Output,  Prev: Incomplete Lines,  Up: Top
1686008e37b6SJohn Marino
1687008e37b6SJohn Marino4 Comparing Directories
1688008e37b6SJohn Marino***********************
1689008e37b6SJohn Marino
1690*6ea1f93eSDaniel FojtYou can use 'diff' to compare some or all of the files in two directory
1691*6ea1f93eSDaniel Fojttrees.  When both file name arguments to 'diff' are directories, it
1692*6ea1f93eSDaniel Fojtcompares each file that is contained in both directories, examining file
1693*6ea1f93eSDaniel Fojtnames in alphabetical order as specified by the 'LC_COLLATE' locale
1694*6ea1f93eSDaniel Fojtcategory.  Normally 'diff' is silent about pairs of files that contain
1695*6ea1f93eSDaniel Fojtno differences, but if you use the '--report-identical-files' ('-s')
1696*6ea1f93eSDaniel Fojtoption, it reports pairs of identical files.  Normally 'diff' reports
1697*6ea1f93eSDaniel Fojtsubdirectories common to both directories without comparing
1698*6ea1f93eSDaniel Fojtsubdirectories' files, but if you use the '-r' or '--recursive' option,
1699*6ea1f93eSDaniel Fojtit compares every corresponding pair of files in the directory trees, as
1700*6ea1f93eSDaniel Fojtmany levels deep as they go.
1701008e37b6SJohn Marino
1702*6ea1f93eSDaniel Fojt   If only one file exists, 'diff' normally does not show its contents;
17034536c563SJohn Marinoit merely reports that one file exists but the other does not.  You can
1704*6ea1f93eSDaniel Fojtmake 'diff' act as though the missing file is empty, so that it outputs
17054536c563SJohn Marinothe entire contents of the file that actually exists.  (It is output as
1706*6ea1f93eSDaniel Fojteither an insertion or a deletion, depending on whether the missing file
1707*6ea1f93eSDaniel Fojtis in the first or the second position.)  To do this, use the
1708*6ea1f93eSDaniel Fojt'--new-file' ('-N') option.  This option affects command-line arguments
1709*6ea1f93eSDaniel Fojtas well as files found via directory traversal; for example, 'diff -N a
1710*6ea1f93eSDaniel Fojtb' treats 'a' as empty if 'a' does not exist but 'b' does, and similarly
1711*6ea1f93eSDaniel Fojt'diff -N - b' treats standard input as empty if it is closed but 'b'
1712*6ea1f93eSDaniel Fojtexists.
1713008e37b6SJohn Marino
1714*6ea1f93eSDaniel Fojt   If the older directory contains large files that are not in the newer
1715*6ea1f93eSDaniel Fojtdirectory, you can make the patch smaller by using the
1716*6ea1f93eSDaniel Fojt'--unidirectional-new-file' option instead of '-N'.  This option is like
1717*6ea1f93eSDaniel Fojt'-N' except that it inserts the contents only of files that appear in
1718*6ea1f93eSDaniel Fojtthe second directory but not the first (that is, files that were added).
1719*6ea1f93eSDaniel FojtAt the top of the patch, write instructions for the user applying the
1720*6ea1f93eSDaniel Fojtpatch to remove the files that were deleted before applying the patch.
1721*6ea1f93eSDaniel Fojt*Note Making Patches::, for more discussion of making patches for
1722*6ea1f93eSDaniel Fojtdistribution.
1723008e37b6SJohn Marino
1724008e37b6SJohn Marino   To ignore some files while comparing directories, use the
1725*6ea1f93eSDaniel Fojt'--exclude=PATTERN' ('-x PATTERN') option.  This option ignores any
1726008e37b6SJohn Marinofiles or subdirectories whose base names match the shell pattern
1727008e37b6SJohn MarinoPATTERN.  Unlike in the shell, a period at the start of the base of a
1728008e37b6SJohn Marinofile name matches a wildcard at the start of a pattern.  You should
1729008e37b6SJohn Marinoenclose PATTERN in quotes so that the shell does not expand it.  For
1730*6ea1f93eSDaniel Fojtexample, the option '-x '*.[ao]'' ignores any file whose name ends with
1731*6ea1f93eSDaniel Fojt'.a' or '.o'.
1732008e37b6SJohn Marino
1733008e37b6SJohn Marino   This option accumulates if you specify it more than once.  For
1734*6ea1f93eSDaniel Fojtexample, using the options '-x 'RCS' -x '*,v'' ignores any file or
1735*6ea1f93eSDaniel Fojtsubdirectory whose base name is 'RCS' or ends with ',v'.
1736008e37b6SJohn Marino
1737008e37b6SJohn Marino   If you need to give this option many times, you can instead put the
1738008e37b6SJohn Marinopatterns in a file, one pattern per line, and use the
1739*6ea1f93eSDaniel Fojt'--exclude-from=FILE' ('-X FILE') option.  Trailing white space and
1740008e37b6SJohn Marinoempty lines are ignored in the pattern file.
1741008e37b6SJohn Marino
1742008e37b6SJohn Marino   If you have been comparing two directories and stopped partway
1743008e37b6SJohn Marinothrough, later you might want to continue where you left off.  You can
1744*6ea1f93eSDaniel Fojtdo this by using the '--starting-file=FILE' ('-S FILE') option.  This
1745008e37b6SJohn Marinocompares only the file FILE and all alphabetically later files in the
1746008e37b6SJohn Marinotopmost directory level.
1747008e37b6SJohn Marino
1748008e37b6SJohn Marino   If two directories differ only in that file names are lower case in
1749*6ea1f93eSDaniel Fojtone directory and upper case in the upper, 'diff' normally reports many
1750008e37b6SJohn Marinodifferences because it compares file names in a case sensitive way.
1751*6ea1f93eSDaniel FojtWith the '--ignore-file-name-case' option, 'diff' ignores case
1752008e37b6SJohn Marinodifferences in file names, so that for example the contents of the file
1753*6ea1f93eSDaniel Fojt'Tao' in one directory are compared to the contents of the file 'TAO' in
1754*6ea1f93eSDaniel Fojtthe other.  The '--no-ignore-file-name-case' option cancels the effect
1755*6ea1f93eSDaniel Fojtof the '--ignore-file-name-case' option, reverting to the default
1756008e37b6SJohn Marinobehavior.
1757008e37b6SJohn Marino
1758*6ea1f93eSDaniel Fojt   If an '--exclude=PATTERN' ('-x PATTERN') option, or an
1759*6ea1f93eSDaniel Fojt'--exclude-from=FILE' ('-X FILE') option, is specified while the
1760*6ea1f93eSDaniel Fojt'--ignore-file-name-case' option is in effect, case is ignored when
1761008e37b6SJohn Marinoexcluding file names matching the specified patterns.
1762008e37b6SJohn Marino
1763*6ea1f93eSDaniel Fojt   To tell 'diff' not to follow a symbolic link, use the
1764*6ea1f93eSDaniel Fojt'--no-dereference' option.
17654536c563SJohn Marino
1766008e37b6SJohn Marino
1767*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Adjusting Output,  Next: diff Performance,  Prev: Comparing Directories,  Up: Top
1768008e37b6SJohn Marino
1769*6ea1f93eSDaniel Fojt5 Making 'diff' Output Prettier
1770008e37b6SJohn Marino*******************************
1771008e37b6SJohn Marino
1772*6ea1f93eSDaniel Fojt'diff' provides several ways to adjust the appearance of its output.
1773008e37b6SJohn MarinoThese adjustments can be applied to any output format.
1774008e37b6SJohn Marino
1775008e37b6SJohn Marino* Menu:
1776008e37b6SJohn Marino
1777008e37b6SJohn Marino* Tabs::            Preserving the alignment of tab stops.
1778008e37b6SJohn Marino* Trailing Blanks:: Suppressing blanks before empty output lines.
1779*6ea1f93eSDaniel Fojt* Pagination::      Page numbering and time-stamping 'diff' output.
1780008e37b6SJohn Marino
1781008e37b6SJohn Marino
1782*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Tabs,  Next: Trailing Blanks,  Up: Adjusting Output
1783008e37b6SJohn Marino
1784008e37b6SJohn Marino5.1 Preserving Tab Stop Alignment
1785008e37b6SJohn Marino=================================
1786008e37b6SJohn Marino
1787*6ea1f93eSDaniel FojtThe lines of text in some of the 'diff' output formats are preceded by
1788008e37b6SJohn Marinoone or two characters that indicate whether the text is inserted,
1789*6ea1f93eSDaniel Fojtdeleted, or changed.  The addition of those characters can cause tabs to
1790*6ea1f93eSDaniel Fojtmove to the next tab stop, throwing off the alignment of columns in the
1791*6ea1f93eSDaniel Fojtline.  GNU 'diff' provides two ways to make tab-aligned columns line up
1792*6ea1f93eSDaniel Fojtcorrectly.
1793008e37b6SJohn Marino
1794*6ea1f93eSDaniel Fojt   The first way is to have 'diff' convert all tabs into the correct
1795008e37b6SJohn Marinonumber of spaces before outputting them; select this method with the
1796*6ea1f93eSDaniel Fojt'--expand-tabs' ('-t') option.  To use this form of output with 'patch',
1797*6ea1f93eSDaniel Fojtyou must give 'patch' the '-l' or '--ignore-white-space' option (*note
1798*6ea1f93eSDaniel FojtChanged White Space::, for more information).  'diff' normally assumes
1799*6ea1f93eSDaniel Fojtthat tab stops are set every 8 print columns, but this can be altered by
1800*6ea1f93eSDaniel Fojtthe '--tabsize=COLUMNS' option.
1801008e37b6SJohn Marino
1802008e37b6SJohn Marino   The other method for making tabs line up correctly is to add a tab
1803008e37b6SJohn Marinocharacter instead of a space after the indicator character at the
1804008e37b6SJohn Marinobeginning of the line.  This ensures that all following tab characters
1805008e37b6SJohn Marinoare in the same position relative to tab stops that they were in the
1806008e37b6SJohn Marinooriginal files, so that the output is aligned correctly.  Its
1807008e37b6SJohn Marinodisadvantage is that it can make long lines too long to fit on one line
1808008e37b6SJohn Marinoof the screen or the paper.  It also does not work with the unified
1809008e37b6SJohn Marinooutput format, which does not have a space character after the change
1810*6ea1f93eSDaniel Fojttype indicator character.  Select this method with the '-T' or
1811*6ea1f93eSDaniel Fojt'--initial-tab' option.
1812008e37b6SJohn Marino
1813008e37b6SJohn Marino
1814*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Trailing Blanks,  Next: Pagination,  Prev: Tabs,  Up: Adjusting Output
1815008e37b6SJohn Marino
1816008e37b6SJohn Marino5.2 Omitting trailing blanks
1817008e37b6SJohn Marino============================
1818008e37b6SJohn Marino
1819008e37b6SJohn MarinoWhen outputting lines in normal or context format, or outputting an
1820*6ea1f93eSDaniel Fojtunchanged line in unified format, 'diff' normally outputs a blank just
1821*6ea1f93eSDaniel Fojtbefore each line.  If the line is empty, the output of 'diff' therefore
1822008e37b6SJohn Marinocontains trailing blanks even though the input does not contain them.
1823008e37b6SJohn MarinoFor example, when outputting an unchanged empty line in context format,
1824*6ea1f93eSDaniel Fojt'diff' normally outputs a line with two leading spaces.
1825008e37b6SJohn Marino
1826008e37b6SJohn Marino   Some text editors and email agents routinely delete trailing blanks,
1827*6ea1f93eSDaniel Fojtso it can be a problem to deal with diff output files that contain them.
1828*6ea1f93eSDaniel FojtYou can avoid this problem with the '--suppress-blank-empty' option.  It
1829*6ea1f93eSDaniel Fojtcauses 'diff' to omit trailing blanks at the end of output lines in
1830*6ea1f93eSDaniel Fojtnormal, context, and unified format, unless the trailing blanks were
1831*6ea1f93eSDaniel Fojtalready present in the input.  This changes the output format slightly,
1832*6ea1f93eSDaniel Fojtso that output lines are guaranteed to never end in a blank unless an
1833*6ea1f93eSDaniel Fojtinput line ends in a blank.  This format is less likely to be munged by
1834*6ea1f93eSDaniel Fojttext editors or by transmission via email.  It is accepted by GNU
1835*6ea1f93eSDaniel Fojt'patch' as well.
1836008e37b6SJohn Marino
1837008e37b6SJohn Marino
1838*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Pagination,  Prev: Trailing Blanks,  Up: Adjusting Output
1839008e37b6SJohn Marino
1840*6ea1f93eSDaniel Fojt5.3 Paginating 'diff' Output
1841008e37b6SJohn Marino============================
1842008e37b6SJohn Marino
1843008e37b6SJohn MarinoIt can be convenient to have long output page-numbered and time-stamped.
1844*6ea1f93eSDaniel FojtThe '--paginate' ('-l') option does this by sending the 'diff' output
1845*6ea1f93eSDaniel Fojtthrough the 'pr' program.  Here is what the page header might look like
1846*6ea1f93eSDaniel Fojtfor 'diff -lc lao tzu':
1847008e37b6SJohn Marino
1848008e37b6SJohn Marino     2002-02-22 14:20                 diff -lc lao tzu                 Page 1
1849008e37b6SJohn Marino
1850008e37b6SJohn Marino
1851*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: diff Performance,  Next: Comparing Three Files,  Prev: Adjusting Output,  Up: Top
1852008e37b6SJohn Marino
1853*6ea1f93eSDaniel Fojt6 'diff' Performance Tradeoffs
1854008e37b6SJohn Marino******************************
1855008e37b6SJohn Marino
1856*6ea1f93eSDaniel FojtGNU 'diff' runs quite efficiently; however, in some circumstances you
1857008e37b6SJohn Marinocan cause it to run faster or produce a more compact set of changes.
1858008e37b6SJohn Marino
1859*6ea1f93eSDaniel Fojt   One way to improve 'diff' performance is to use hard or symbolic
1860008e37b6SJohn Marinolinks to files instead of copies.  This improves performance because
1861*6ea1f93eSDaniel Fojt'diff' normally does not need to read two hard or symbolic links to the
1862*6ea1f93eSDaniel Fojtsame file, since their contents must be identical.  For example, suppose
1863*6ea1f93eSDaniel Fojtyou copy a large directory hierarchy, make a few changes to the copy,
1864*6ea1f93eSDaniel Fojtand then often use 'diff -r' to compare the original to the copy.  If
1865*6ea1f93eSDaniel Fojtthe original files are read-only, you can greatly improve performance by
1866*6ea1f93eSDaniel Fojtcreating the copy using hard or symbolic links (e.g., with GNU 'cp -lR'
1867*6ea1f93eSDaniel Fojtor 'cp -sR').  Before editing a file in the copy for the first time, you
1868*6ea1f93eSDaniel Fojtshould break the link and replace it with a regular copy.
1869008e37b6SJohn Marino
1870*6ea1f93eSDaniel Fojt   You can also affect the performance of GNU 'diff' by giving it
1871008e37b6SJohn Marinooptions that change the way it compares files.  Performance has more
1872008e37b6SJohn Marinothan one dimension.  These options improve one aspect of performance at
1873008e37b6SJohn Marinothe cost of another, or they improve performance in some cases while
1874008e37b6SJohn Marinohurting it in others.
1875008e37b6SJohn Marino
1876*6ea1f93eSDaniel Fojt   The way that GNU 'diff' determines which lines have changed always
1877008e37b6SJohn Marinocomes up with a near-minimal set of differences.  Usually it is good
1878*6ea1f93eSDaniel Fojtenough for practical purposes.  If the 'diff' output is large, you might
1879*6ea1f93eSDaniel Fojtwant 'diff' to use a modified algorithm that sometimes produces a
1880*6ea1f93eSDaniel Fojtsmaller set of differences.  The '--minimal' ('-d') option does this;
1881*6ea1f93eSDaniel Fojthowever, it can also cause 'diff' to run more slowly than usual, so it
1882008e37b6SJohn Marinois not the default behavior.
1883008e37b6SJohn Marino
1884008e37b6SJohn Marino   When the files you are comparing are large and have small groups of
1885*6ea1f93eSDaniel Fojtchanges scattered throughout them, you can use the '--speed-large-files'
1886*6ea1f93eSDaniel Fojtoption to make a different modification to the algorithm that 'diff'
1887*6ea1f93eSDaniel Fojtuses.  If the input files have a constant small density of changes, this
1888*6ea1f93eSDaniel Fojtoption speeds up the comparisons without changing the output.  If not,
1889*6ea1f93eSDaniel Fojt'diff' might produce a larger set of differences; however, the output
1890*6ea1f93eSDaniel Fojtwill still be correct.
1891008e37b6SJohn Marino
1892*6ea1f93eSDaniel Fojt   Normally 'diff' discards the prefix and suffix that is common to both
1893*6ea1f93eSDaniel Fojtfiles before it attempts to find a minimal set of differences.  This
1894*6ea1f93eSDaniel Fojtmakes 'diff' run faster, but occasionally it may produce non-minimal
1895*6ea1f93eSDaniel Fojtoutput.  The '--horizon-lines=LINES' option prevents 'diff' from
1896*6ea1f93eSDaniel Fojtdiscarding the last LINES lines of the prefix and the first LINES lines
1897*6ea1f93eSDaniel Fojtof the suffix.  This gives 'diff' further opportunities to find a
1898008e37b6SJohn Marinominimal output.
1899008e37b6SJohn Marino
1900008e37b6SJohn Marino   Suppose a run of changed lines includes a sequence of lines at one
1901008e37b6SJohn Marinoend and there is an identical sequence of lines just outside the other
1902*6ea1f93eSDaniel Fojtend.  The 'diff' command is free to choose which identical sequence is
1903*6ea1f93eSDaniel Fojtincluded in the hunk.  In this case, 'diff' normally shifts the hunk's
1904008e37b6SJohn Marinoboundaries when this merges adjacent hunks, or shifts a hunk's lines
1905008e37b6SJohn Marinotowards the end of the file.  Merging hunks can make the output look
1906008e37b6SJohn Marinonicer in some cases.
1907008e37b6SJohn Marino
1908008e37b6SJohn Marino
1909*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Comparing Three Files,  Next: diff3 Merging,  Prev: diff Performance,  Up: Top
1910008e37b6SJohn Marino
1911008e37b6SJohn Marino7 Comparing Three Files
1912008e37b6SJohn Marino***********************
1913008e37b6SJohn Marino
1914*6ea1f93eSDaniel FojtUse the program 'diff3' to compare three files and show any differences
1915*6ea1f93eSDaniel Fojtamong them.  ('diff3' can also merge files; see *note diff3 Merging::).
1916008e37b6SJohn Marino
1917*6ea1f93eSDaniel Fojt   The "normal" 'diff3' output format shows each hunk of differences
1918008e37b6SJohn Marinowithout surrounding context.  Hunks are labeled depending on whether
1919*6ea1f93eSDaniel Fojtthey are two-way or three-way, and lines are annotated by their location
1920*6ea1f93eSDaniel Fojtin the input files.
1921008e37b6SJohn Marino
1922*6ea1f93eSDaniel Fojt   *Note Invoking diff3::, for more information on how to run 'diff3'.
1923008e37b6SJohn Marino
1924008e37b6SJohn Marino* Menu:
1925008e37b6SJohn Marino
1926*6ea1f93eSDaniel Fojt* Sample diff3 Input::    Sample 'diff3' input for examples.
1927008e37b6SJohn Marino* Example diff3 Normal::  Sample output in the normal format.
1928008e37b6SJohn Marino* Detailed diff3 Normal:: A detailed description of normal output format.
19294536c563SJohn Marino* diff3 Hunks::           The format of normal output format.
1930008e37b6SJohn Marino
1931008e37b6SJohn Marino
1932*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Sample diff3 Input,  Next: Example diff3 Normal,  Up: Comparing Three Files
1933008e37b6SJohn Marino
1934008e37b6SJohn Marino7.1 A Third Sample Input File
1935008e37b6SJohn Marino=============================
1936008e37b6SJohn Marino
1937008e37b6SJohn MarinoHere is a third sample file that will be used in examples to illustrate
1938*6ea1f93eSDaniel Fojtthe output of 'diff3' and how various options can change it.  The first
1939*6ea1f93eSDaniel Fojttwo files are the same that we used for 'diff' (*note Sample diff
1940*6ea1f93eSDaniel FojtInput::).  This is the third sample file, called 'tao':
1941008e37b6SJohn Marino
1942008e37b6SJohn Marino     The Way that can be told of is not the eternal Way;
1943008e37b6SJohn Marino     The name that can be named is not the eternal name.
1944008e37b6SJohn Marino     The Nameless is the origin of Heaven and Earth;
1945008e37b6SJohn Marino     The named is the mother of all things.
1946008e37b6SJohn Marino
1947008e37b6SJohn Marino     Therefore let there always be non-being,
1948008e37b6SJohn Marino       so we may see their subtlety,
1949008e37b6SJohn Marino     And let there always be being,
1950008e37b6SJohn Marino       so we may see their result.
1951008e37b6SJohn Marino     The two are the same,
1952008e37b6SJohn Marino     But after they are produced,
1953008e37b6SJohn Marino       they have different names.
1954008e37b6SJohn Marino
1955008e37b6SJohn Marino       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1956008e37b6SJohn Marino
1957008e37b6SJohn Marino
1958*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Example diff3 Normal,  Next: Detailed diff3 Normal,  Prev: Sample diff3 Input,  Up: Comparing Three Files
1959008e37b6SJohn Marino
1960*6ea1f93eSDaniel Fojt7.2 An Example of 'diff3' Normal Format
1961008e37b6SJohn Marino=======================================
1962008e37b6SJohn Marino
1963*6ea1f93eSDaniel FojtHere is the output of the command 'diff3 lao tzu tao' (*note Sample
1964008e37b6SJohn Marinodiff3 Input::, for the complete contents of the files).  Notice that it
1965008e37b6SJohn Marinoshows only the lines that are different among the three files.
1966008e37b6SJohn Marino
1967008e37b6SJohn Marino     ====2
1968008e37b6SJohn Marino     1:1,2c
1969008e37b6SJohn Marino     3:1,2c
1970008e37b6SJohn Marino       The Way that can be told of is not the eternal Way;
1971008e37b6SJohn Marino       The name that can be named is not the eternal name.
1972008e37b6SJohn Marino     2:0a
1973008e37b6SJohn Marino     ====1
1974008e37b6SJohn Marino     1:4c
1975008e37b6SJohn Marino       The Named is the mother of all things.
1976008e37b6SJohn Marino     2:2,3c
1977008e37b6SJohn Marino     3:4,5c
1978008e37b6SJohn Marino       The named is the mother of all things.
1979008e37b6SJohn Marino
1980008e37b6SJohn Marino     ====3
1981008e37b6SJohn Marino     1:8c
1982008e37b6SJohn Marino     2:7c
1983008e37b6SJohn Marino         so we may see their outcome.
1984008e37b6SJohn Marino     3:9c
1985008e37b6SJohn Marino         so we may see their result.
1986008e37b6SJohn Marino     ====
1987008e37b6SJohn Marino     1:11a
1988008e37b6SJohn Marino     2:11,13c
1989008e37b6SJohn Marino       They both may be called deep and profound.
1990008e37b6SJohn Marino       Deeper and more profound,
1991008e37b6SJohn Marino       The door of all subtleties!
1992008e37b6SJohn Marino     3:13,14c
1993008e37b6SJohn Marino
1994008e37b6SJohn Marino         -- The Way of Lao-Tzu, tr. Wing-tsit Chan
1995008e37b6SJohn Marino
1996008e37b6SJohn Marino
1997*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Detailed diff3 Normal,  Next: diff3 Hunks,  Prev: Example diff3 Normal,  Up: Comparing Three Files
1998008e37b6SJohn Marino
1999*6ea1f93eSDaniel Fojt7.3 Detailed Description of 'diff3' Normal Format
2000008e37b6SJohn Marino=================================================
2001008e37b6SJohn Marino
2002*6ea1f93eSDaniel FojtEach hunk begins with a line marked '===='.  Three-way hunks have plain
2003*6ea1f93eSDaniel Fojt'====' lines, and two-way hunks have '1', '2', or '3' appended to
2004008e37b6SJohn Marinospecify which of the three input files differ in that hunk.  The hunks
2005008e37b6SJohn Marinocontain copies of two or three sets of input lines each preceded by one
2006008e37b6SJohn Marinoor two commands identifying where the lines came from.
2007008e37b6SJohn Marino
2008008e37b6SJohn Marino   Normally, two spaces precede each copy of an input line to
2009*6ea1f93eSDaniel Fojtdistinguish it from the commands.  But with the '--initial-tab' ('-T')
2010*6ea1f93eSDaniel Fojtoption, 'diff3' uses a tab instead of two spaces; this lines up tabs
2011008e37b6SJohn Marinocorrectly.  *Note Tabs::, for more information.
2012008e37b6SJohn Marino
2013008e37b6SJohn Marino   Commands take the following forms:
2014008e37b6SJohn Marino
2015*6ea1f93eSDaniel Fojt'FILE:La'
2016008e37b6SJohn Marino     This hunk appears after line L of file FILE, and contains no lines
2017*6ea1f93eSDaniel Fojt     in that file.  To edit this file to yield the other files, one must
2018*6ea1f93eSDaniel Fojt     append hunk lines taken from the other files.  For example, '1:11a'
2019*6ea1f93eSDaniel Fojt     means that the hunk follows line 11 in the first file and contains
2020*6ea1f93eSDaniel Fojt     no lines from that file.
2021008e37b6SJohn Marino
2022*6ea1f93eSDaniel Fojt'FILE:Rc'
2023008e37b6SJohn Marino     This hunk contains the lines in the range R of file FILE.  The
2024008e37b6SJohn Marino     range R is a comma-separated pair of line numbers, or just one
2025008e37b6SJohn Marino     number if there is only one line.  To edit this file to yield the
2026008e37b6SJohn Marino     other files, one must change the specified lines to be the lines
2027*6ea1f93eSDaniel Fojt     taken from the other files.  For example, '2:11,13c' means that the
2028*6ea1f93eSDaniel Fojt     hunk contains lines 11 through 13 from the second file.
2029008e37b6SJohn Marino
2030008e37b6SJohn Marino   If the last line in a set of input lines is incomplete (*note
2031*6ea1f93eSDaniel FojtIncomplete Lines::), it is distinguished on output from a full line by a
2032*6ea1f93eSDaniel Fojtfollowing line that starts with '\'.
2033008e37b6SJohn Marino
2034008e37b6SJohn Marino
2035*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: diff3 Hunks,  Prev: Detailed diff3 Normal,  Up: Comparing Three Files
2036008e37b6SJohn Marino
2037*6ea1f93eSDaniel Fojt7.4 'diff3' Hunks
2038008e37b6SJohn Marino=================
2039008e37b6SJohn Marino
2040008e37b6SJohn MarinoGroups of lines that differ in two or three of the input files are
2041*6ea1f93eSDaniel Fojtcalled "diff3 hunks", by analogy with 'diff' hunks (*note Hunks::).  If
2042*6ea1f93eSDaniel Fojtall three input files differ in a 'diff3' hunk, the hunk is called a
2043008e37b6SJohn Marino"three-way hunk"; if just two input files differ, it is a "two-way
2044008e37b6SJohn Marinohunk".
2045008e37b6SJohn Marino
2046*6ea1f93eSDaniel Fojt   As with 'diff', several solutions are possible.  When comparing the
2047*6ea1f93eSDaniel Fojtfiles 'A', 'B', and 'C', 'diff3' normally finds 'diff3' hunks by merging
2048*6ea1f93eSDaniel Fojtthe two-way hunks output by the two commands 'diff A B' and 'diff A C'.
2049*6ea1f93eSDaniel FojtThis does not necessarily minimize the size of the output, but
2050*6ea1f93eSDaniel Fojtexceptions should be rare.
2051008e37b6SJohn Marino
2052*6ea1f93eSDaniel Fojt   For example, suppose 'F' contains the three lines 'a', 'b', 'f', 'G'
2053*6ea1f93eSDaniel Fojtcontains the lines 'g', 'b', 'g', and 'H' contains the lines 'a', 'b',
2054*6ea1f93eSDaniel Fojt'h'.  'diff3 F G H' might output the following:
2055008e37b6SJohn Marino
2056008e37b6SJohn Marino     ====2
2057008e37b6SJohn Marino     1:1c
2058008e37b6SJohn Marino     3:1c
2059008e37b6SJohn Marino       a
2060008e37b6SJohn Marino     2:1c
2061008e37b6SJohn Marino       g
2062008e37b6SJohn Marino     ====
2063008e37b6SJohn Marino     1:3c
2064008e37b6SJohn Marino       f
2065008e37b6SJohn Marino     2:3c
2066008e37b6SJohn Marino       g
2067008e37b6SJohn Marino     3:3c
2068008e37b6SJohn Marino       h
2069008e37b6SJohn Marino
2070*6ea1f93eSDaniel Fojtbecause it found a two-way hunk containing 'a' in the first and third
2071*6ea1f93eSDaniel Fojtfiles and 'g' in the second file, then the single line 'b' common to all
2072*6ea1f93eSDaniel Fojtthree files, then a three-way hunk containing the last line of each
2073008e37b6SJohn Marinofile.
2074008e37b6SJohn Marino
2075008e37b6SJohn Marino
2076*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: diff3 Merging,  Next: Interactive Merging,  Prev: Comparing Three Files,  Up: Top
2077008e37b6SJohn Marino
2078008e37b6SJohn Marino8 Merging From a Common Ancestor
2079008e37b6SJohn Marino********************************
2080008e37b6SJohn Marino
2081*6ea1f93eSDaniel FojtWhen two people have made changes to copies of the same file, 'diff3'
2082008e37b6SJohn Marinocan produce a merged output that contains both sets of changes together
2083008e37b6SJohn Marinowith warnings about conflicts.
2084008e37b6SJohn Marino
2085*6ea1f93eSDaniel Fojt   One might imagine programs with names like 'diff4' and 'diff5' to
2086008e37b6SJohn Marinocompare more than three files simultaneously, but in practice the need
2087*6ea1f93eSDaniel Fojtrarely arises.  You can use 'diff3' to merge three or more sets of
2088008e37b6SJohn Marinochanges to a file by merging two change sets at a time.
2089008e37b6SJohn Marino
2090*6ea1f93eSDaniel Fojt   'diff3' can incorporate changes from two modified versions into a
2091008e37b6SJohn Marinocommon preceding version.  This lets you merge the sets of changes
2092008e37b6SJohn Marinorepresented by the two newer files.  Specify the common ancestor version
2093008e37b6SJohn Marinoas the second argument and the two newer versions as the first and third
2094008e37b6SJohn Marinoarguments, like this:
2095008e37b6SJohn Marino
2096008e37b6SJohn Marino     diff3 MINE OLDER YOURS
2097008e37b6SJohn Marino
2098008e37b6SJohn MarinoYou can remember the order of the arguments by noting that they are in
2099008e37b6SJohn Marinoalphabetical order.
2100008e37b6SJohn Marino
2101008e37b6SJohn Marino   You can think of this as subtracting OLDER from YOURS and adding the
2102008e37b6SJohn Marinoresult to MINE, or as merging into MINE the changes that would turn
2103008e37b6SJohn MarinoOLDER into YOURS.  This merging is well-defined as long as MINE and
2104008e37b6SJohn MarinoOLDER match in the neighborhood of each such change.  This fails to be
2105008e37b6SJohn Marinotrue when all three input files differ or when only OLDER differs; we
2106008e37b6SJohn Marinocall this a "conflict".  When all three input files differ, we call the
2107008e37b6SJohn Marinoconflict an "overlap".
2108008e37b6SJohn Marino
2109*6ea1f93eSDaniel Fojt   'diff3' gives you several ways to handle overlaps and conflicts.  You
2110*6ea1f93eSDaniel Fojtcan omit overlaps or conflicts, or select only overlaps, or mark
2111*6ea1f93eSDaniel Fojtconflicts with special '<<<<<<<' and '>>>>>>>' lines.
2112008e37b6SJohn Marino
2113*6ea1f93eSDaniel Fojt   'diff3' can output the merge results as an 'ed' script that that can
2114*6ea1f93eSDaniel Fojtbe applied to the first file to yield the merged output.  However, it is
2115*6ea1f93eSDaniel Fojtusually better to have 'diff3' generate the merged output directly; this
2116*6ea1f93eSDaniel Fojtbypasses some problems with 'ed'.
2117008e37b6SJohn Marino
2118008e37b6SJohn Marino* Menu:
2119008e37b6SJohn Marino
2120008e37b6SJohn Marino* Which Changes::            Selecting changes to incorporate.
2121008e37b6SJohn Marino* Marking Conflicts::        Marking conflicts.
2122008e37b6SJohn Marino* Bypassing ed::             Generating merged output directly.
2123*6ea1f93eSDaniel Fojt* Merging Incomplete Lines:: How 'diff3' merges incomplete lines.
2124008e37b6SJohn Marino* Saving the Changed File::  Emulating System V behavior.
2125008e37b6SJohn Marino
2126008e37b6SJohn Marino
2127*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Which Changes,  Next: Marking Conflicts,  Up: diff3 Merging
2128008e37b6SJohn Marino
2129008e37b6SJohn Marino8.1 Selecting Which Changes to Incorporate
2130008e37b6SJohn Marino==========================================
2131008e37b6SJohn Marino
2132*6ea1f93eSDaniel FojtYou can select all unmerged changes from OLDER to YOURS for merging into
2133*6ea1f93eSDaniel FojtMINE with the '--ed' ('-e') option.  You can select only the
2134*6ea1f93eSDaniel Fojtnonoverlapping unmerged changes with '--easy-only' ('-3'), and you can
2135*6ea1f93eSDaniel Fojtselect only the overlapping changes with '--overlap-only' ('-x').
2136008e37b6SJohn Marino
2137*6ea1f93eSDaniel Fojt   The '-e', '-3' and '-x' options select only "unmerged changes", i.e.
2138008e37b6SJohn Marinochanges where MINE and YOURS differ; they ignore changes from OLDER to
2139008e37b6SJohn MarinoYOURS where MINE and YOURS are identical, because they assume that such
2140*6ea1f93eSDaniel Fojtchanges have already been merged.  If this assumption is not a safe one,
2141*6ea1f93eSDaniel Fojtyou can use the '--show-all' ('-A') option (*note Marking Conflicts::).
2142008e37b6SJohn Marino
2143*6ea1f93eSDaniel Fojt   Here is the output of the command 'diff3' with each of these three
2144008e37b6SJohn Marinooptions (*note Sample diff3 Input::, for the complete contents of the
2145*6ea1f93eSDaniel Fojtfiles).  Notice that '-e' outputs the union of the disjoint sets of
2146*6ea1f93eSDaniel Fojtchanges output by '-3' and '-x'.
2147008e37b6SJohn Marino
2148*6ea1f93eSDaniel Fojt   Output of 'diff3 -e lao tzu tao':
2149008e37b6SJohn Marino     11a
2150008e37b6SJohn Marino
2151008e37b6SJohn Marino       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2152008e37b6SJohn Marino     .
2153008e37b6SJohn Marino     8c
2154008e37b6SJohn Marino       so we may see their result.
2155008e37b6SJohn Marino     .
2156008e37b6SJohn Marino
2157*6ea1f93eSDaniel Fojt   Output of 'diff3 -3 lao tzu tao':
2158008e37b6SJohn Marino     8c
2159008e37b6SJohn Marino       so we may see their result.
2160008e37b6SJohn Marino     .
2161008e37b6SJohn Marino
2162*6ea1f93eSDaniel Fojt   Output of 'diff3 -x lao tzu tao':
2163008e37b6SJohn Marino     11a
2164008e37b6SJohn Marino
2165008e37b6SJohn Marino       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2166008e37b6SJohn Marino     .
2167008e37b6SJohn Marino
2168008e37b6SJohn Marino
2169*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Marking Conflicts,  Next: Bypassing ed,  Prev: Which Changes,  Up: diff3 Merging
2170008e37b6SJohn Marino
2171008e37b6SJohn Marino8.2 Marking Conflicts
2172008e37b6SJohn Marino=====================
2173008e37b6SJohn Marino
2174*6ea1f93eSDaniel Fojt'diff3' can mark conflicts in the merged output by bracketing them with
2175008e37b6SJohn Marinospecial marker lines.  A conflict that comes from two files A and B is
2176008e37b6SJohn Marinomarked as follows:
2177008e37b6SJohn Marino
2178008e37b6SJohn Marino     <<<<<<< A
2179008e37b6SJohn Marino     lines from A
2180008e37b6SJohn Marino     =======
2181008e37b6SJohn Marino     lines from B
2182008e37b6SJohn Marino     >>>>>>> B
2183008e37b6SJohn Marino
2184008e37b6SJohn Marino   A conflict that comes from three files A, B and C is marked as
2185008e37b6SJohn Marinofollows:
2186008e37b6SJohn Marino
2187008e37b6SJohn Marino     <<<<<<< A
2188008e37b6SJohn Marino     lines from A
2189008e37b6SJohn Marino     ||||||| B
2190008e37b6SJohn Marino     lines from B
2191008e37b6SJohn Marino     =======
2192008e37b6SJohn Marino     lines from C
2193008e37b6SJohn Marino     >>>>>>> C
2194008e37b6SJohn Marino
2195*6ea1f93eSDaniel Fojt   The '--show-all' ('-A') option acts like the '-e' option, except that
2196*6ea1f93eSDaniel Fojtit brackets conflicts, and it outputs all changes from OLDER to YOURS,
2197*6ea1f93eSDaniel Fojtnot just the unmerged changes.  Thus, given the sample input files
2198*6ea1f93eSDaniel Fojt(*note Sample diff3 Input::), 'diff3 -A lao tzu tao' puts brackets
2199*6ea1f93eSDaniel Fojtaround the conflict where only 'tzu' differs:
2200008e37b6SJohn Marino
2201008e37b6SJohn Marino     <<<<<<< tzu
2202008e37b6SJohn Marino     =======
2203008e37b6SJohn Marino     The Way that can be told of is not the eternal Way;
2204008e37b6SJohn Marino     The name that can be named is not the eternal name.
2205008e37b6SJohn Marino     >>>>>>> tao
2206008e37b6SJohn Marino
2207008e37b6SJohn Marino   And it outputs the three-way conflict as follows:
2208008e37b6SJohn Marino
2209008e37b6SJohn Marino     <<<<<<< lao
2210008e37b6SJohn Marino     ||||||| tzu
2211008e37b6SJohn Marino     They both may be called deep and profound.
2212008e37b6SJohn Marino     Deeper and more profound,
2213008e37b6SJohn Marino     The door of all subtleties!
2214008e37b6SJohn Marino     =======
2215008e37b6SJohn Marino
2216008e37b6SJohn Marino       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2217008e37b6SJohn Marino     >>>>>>> tao
2218008e37b6SJohn Marino
2219*6ea1f93eSDaniel Fojt   The '--show-overlap' ('-E') option outputs less information than the
2220*6ea1f93eSDaniel Fojt'--show-all' ('-A') option, because it outputs only unmerged changes,
2221*6ea1f93eSDaniel Fojtand it never outputs the contents of the second file.  Thus the '-E'
2222*6ea1f93eSDaniel Fojtoption acts like the '-e' option, except that it brackets the first and
2223*6ea1f93eSDaniel Fojtthird files from three-way overlapping changes.  Similarly, '-X' acts
2224*6ea1f93eSDaniel Fojtlike '-x', except it brackets all its (necessarily overlapping) changes.
2225*6ea1f93eSDaniel FojtFor example, for the three-way overlapping change above, the '-E' and
2226*6ea1f93eSDaniel Fojt'-X' options output the following:
2227008e37b6SJohn Marino
2228008e37b6SJohn Marino     <<<<<<< lao
2229008e37b6SJohn Marino     =======
2230008e37b6SJohn Marino
2231008e37b6SJohn Marino       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2232008e37b6SJohn Marino     >>>>>>> tao
2233008e37b6SJohn Marino
2234008e37b6SJohn Marino   If you are comparing files that have meaningless or uninformative
2235*6ea1f93eSDaniel Fojtnames, you can use the '--label=LABEL' option to show alternate names in
2236*6ea1f93eSDaniel Fojtthe '<<<<<<<', '|||||||' and '>>>>>>>' brackets.  This option can be
2237*6ea1f93eSDaniel Fojtgiven up to three times, once for each input file.  Thus 'diff3 -A
2238*6ea1f93eSDaniel Fojt--label X --label Y --label Z A B C' acts like 'diff3 -A A B C', except
2239*6ea1f93eSDaniel Fojtthat the output looks like it came from files named 'X', 'Y' and 'Z'
2240*6ea1f93eSDaniel Fojtrather than from files named 'A', 'B' and 'C'.
2241008e37b6SJohn Marino
2242008e37b6SJohn Marino
2243*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Bypassing ed,  Next: Merging Incomplete Lines,  Prev: Marking Conflicts,  Up: diff3 Merging
2244008e37b6SJohn Marino
2245008e37b6SJohn Marino8.3 Generating the Merged Output Directly
2246008e37b6SJohn Marino=========================================
2247008e37b6SJohn Marino
2248*6ea1f93eSDaniel FojtWith the '--merge' ('-m') option, 'diff3' outputs the merged file
2249*6ea1f93eSDaniel Fojtdirectly.  This is more efficient than using 'ed' to generate it, and
2250*6ea1f93eSDaniel Fojtworks even with non-text files that 'ed' would reject.  If you specify
2251*6ea1f93eSDaniel Fojt'-m' without an 'ed' script option, '-A' is assumed.
2252008e37b6SJohn Marino
2253*6ea1f93eSDaniel Fojt   For example, the command 'diff3 -m lao tzu tao' (*note Sample diff3
2254008e37b6SJohn MarinoInput:: for a copy of the input files) would output the following:
2255008e37b6SJohn Marino
2256008e37b6SJohn Marino     <<<<<<< tzu
2257008e37b6SJohn Marino     =======
2258008e37b6SJohn Marino     The Way that can be told of is not the eternal Way;
2259008e37b6SJohn Marino     The name that can be named is not the eternal name.
2260008e37b6SJohn Marino     >>>>>>> tao
2261008e37b6SJohn Marino     The Nameless is the origin of Heaven and Earth;
2262008e37b6SJohn Marino     The Named is the mother of all things.
2263008e37b6SJohn Marino     Therefore let there always be non-being,
2264008e37b6SJohn Marino       so we may see their subtlety,
2265008e37b6SJohn Marino     And let there always be being,
2266008e37b6SJohn Marino       so we may see their result.
2267008e37b6SJohn Marino     The two are the same,
2268008e37b6SJohn Marino     But after they are produced,
2269008e37b6SJohn Marino       they have different names.
2270008e37b6SJohn Marino     <<<<<<< lao
2271008e37b6SJohn Marino     ||||||| tzu
2272008e37b6SJohn Marino     They both may be called deep and profound.
2273008e37b6SJohn Marino     Deeper and more profound,
2274008e37b6SJohn Marino     The door of all subtleties!
2275008e37b6SJohn Marino     =======
2276008e37b6SJohn Marino
2277008e37b6SJohn Marino       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
2278008e37b6SJohn Marino     >>>>>>> tao
2279008e37b6SJohn Marino
2280008e37b6SJohn Marino
2281*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Merging Incomplete Lines,  Next: Saving the Changed File,  Prev: Bypassing ed,  Up: diff3 Merging
2282008e37b6SJohn Marino
2283*6ea1f93eSDaniel Fojt8.4 How 'diff3' Merges Incomplete Lines
2284008e37b6SJohn Marino=======================================
2285008e37b6SJohn Marino
2286*6ea1f93eSDaniel FojtWith '-m', incomplete lines (*note Incomplete Lines::) are simply copied
2287*6ea1f93eSDaniel Fojtto the output as they are found; if the merged output ends in an
2288008e37b6SJohn Marinoconflict and one of the input files ends in an incomplete line,
2289*6ea1f93eSDaniel Fojtsucceeding '|||||||', '=======' or '>>>>>>>' brackets appear somewhere
2290008e37b6SJohn Marinoother than the start of a line because they are appended to the
2291008e37b6SJohn Marinoincomplete line.
2292008e37b6SJohn Marino
2293*6ea1f93eSDaniel Fojt   Without '-m', if an 'ed' script option is specified and an incomplete
2294*6ea1f93eSDaniel Fojtline is found, 'diff3' generates a warning and acts as if a newline had
2295*6ea1f93eSDaniel Fojtbeen present.
2296008e37b6SJohn Marino
2297008e37b6SJohn Marino
2298*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Saving the Changed File,  Prev: Merging Incomplete Lines,  Up: diff3 Merging
2299008e37b6SJohn Marino
2300008e37b6SJohn Marino8.5 Saving the Changed File
2301008e37b6SJohn Marino===========================
2302008e37b6SJohn Marino
2303*6ea1f93eSDaniel FojtTraditional Unix 'diff3' generates an 'ed' script without the trailing
2304*6ea1f93eSDaniel Fojt'w' and 'q' commands that save the changes.  System V 'diff3' generates
2305*6ea1f93eSDaniel Fojtthese extra commands.  GNU 'diff3' normally behaves like traditional
2306*6ea1f93eSDaniel FojtUnix 'diff3', but with the '-i' option it behaves like System V 'diff3'
2307*6ea1f93eSDaniel Fojtand appends the 'w' and 'q' commands.
2308008e37b6SJohn Marino
2309*6ea1f93eSDaniel Fojt   The '-i' option requires one of the 'ed' script options '-AeExX3',
2310*6ea1f93eSDaniel Fojtand is incompatible with the merged output option '-m'.
2311008e37b6SJohn Marino
2312008e37b6SJohn Marino
2313*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Interactive Merging,  Next: Merging with patch,  Prev: diff3 Merging,  Up: Top
2314008e37b6SJohn Marino
2315*6ea1f93eSDaniel Fojt9 Interactive Merging with 'sdiff'
2316008e37b6SJohn Marino**********************************
2317008e37b6SJohn Marino
2318*6ea1f93eSDaniel FojtWith 'sdiff', you can merge two files interactively based on a
2319*6ea1f93eSDaniel Fojtside-by-side '-y' format comparison (*note Side by Side::).  Use
2320*6ea1f93eSDaniel Fojt'--output=FILE' ('-o FILE') to specify where to put the merged text.
2321*6ea1f93eSDaniel Fojt*Note Invoking sdiff::, for more details on the options to 'sdiff'.
2322008e37b6SJohn Marino
2323008e37b6SJohn Marino   Another way to merge files interactively is to use the Emacs Lisp
2324*6ea1f93eSDaniel Fojtpackage 'emerge'.  *Note Emerge: (emacs)Emerge, for more information.
2325008e37b6SJohn Marino
2326008e37b6SJohn Marino* Menu:
2327008e37b6SJohn Marino
2328*6ea1f93eSDaniel Fojt* sdiff Option Summary:: Summary of 'sdiff' options.
2329008e37b6SJohn Marino* Merge Commands::       Merging two files interactively.
2330008e37b6SJohn Marino
2331008e37b6SJohn Marino
2332*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: sdiff Option Summary,  Next: Merge Commands,  Up: Interactive Merging
2333008e37b6SJohn Marino
2334*6ea1f93eSDaniel Fojt9.1 Specifying 'diff' Options to 'sdiff'
2335008e37b6SJohn Marino========================================
2336008e37b6SJohn Marino
2337*6ea1f93eSDaniel FojtThe following 'sdiff' options have the same meaning as for 'diff'.
2338008e37b6SJohn Marino*Note diff Options::, for the use of these options.
2339008e37b6SJohn Marino
2340008e37b6SJohn Marino     -a -b -d -i -t -v
2341008e37b6SJohn Marino     -B -E -I REGEXP -Z
2342008e37b6SJohn Marino
2343008e37b6SJohn Marino     --expand-tabs
2344008e37b6SJohn Marino     --ignore-blank-lines  --ignore-case
2345008e37b6SJohn Marino     --ignore-matching-lines=REGEXP  --ignore-space-change
2346008e37b6SJohn Marino     --ignore-tab-expansion  --ignore-trailing-space
2347008e37b6SJohn Marino     --left-column  --minimal  --speed-large-files
2348008e37b6SJohn Marino     --strip-trailing-cr  --suppress-common-lines
2349008e37b6SJohn Marino     --tabsize=COLUMNS  --text  --version  --width=COLUMNS
2350008e37b6SJohn Marino
2351*6ea1f93eSDaniel Fojt   For historical reasons, 'sdiff' has alternate names for some options.
2352*6ea1f93eSDaniel FojtThe '-l' option is equivalent to the '--left-column' option, and
2353*6ea1f93eSDaniel Fojtsimilarly '-s' is equivalent to '--suppress-common-lines'.  The meaning
2354*6ea1f93eSDaniel Fojtof the 'sdiff' '-w' and '-W' options is interchanged from that of
2355*6ea1f93eSDaniel Fojt'diff': with 'sdiff', '-w COLUMNS' is equivalent to '--width=COLUMNS',
2356*6ea1f93eSDaniel Fojtand '-W' is equivalent to '--ignore-all-space'.  'sdiff' without the
2357*6ea1f93eSDaniel Fojt'-o' option is equivalent to 'diff' with the '--side-by-side' ('-y')
2358*6ea1f93eSDaniel Fojtoption (*note Side by Side::).
2359008e37b6SJohn Marino
2360008e37b6SJohn Marino
2361*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Merge Commands,  Prev: sdiff Option Summary,  Up: Interactive Merging
2362008e37b6SJohn Marino
2363008e37b6SJohn Marino9.2 Merge Commands
2364008e37b6SJohn Marino==================
2365008e37b6SJohn Marino
2366008e37b6SJohn MarinoGroups of common lines, with a blank gutter, are copied from the first
2367*6ea1f93eSDaniel Fojtfile to the output.  After each group of differing lines, 'sdiff'
2368*6ea1f93eSDaniel Fojtprompts with '%' and pauses, waiting for one of the following commands.
2369008e37b6SJohn MarinoFollow each command with <RET>.
2370008e37b6SJohn Marino
2371*6ea1f93eSDaniel Fojt'e'
2372008e37b6SJohn Marino     Discard both versions.  Invoke a text editor on an empty temporary
2373008e37b6SJohn Marino     file, then copy the resulting file to the output.
2374008e37b6SJohn Marino
2375*6ea1f93eSDaniel Fojt'eb'
2376008e37b6SJohn Marino     Concatenate the two versions, edit the result in a temporary file,
2377008e37b6SJohn Marino     then copy the edited result to the output.
2378008e37b6SJohn Marino
2379*6ea1f93eSDaniel Fojt'ed'
2380*6ea1f93eSDaniel Fojt     Like 'eb', except precede each version with a header that shows
2381008e37b6SJohn Marino     what file and lines the version came from.
2382008e37b6SJohn Marino
2383*6ea1f93eSDaniel Fojt'el'
2384*6ea1f93eSDaniel Fojt'e1'
2385008e37b6SJohn Marino     Edit a copy of the left version, then copy the result to the
2386008e37b6SJohn Marino     output.
2387008e37b6SJohn Marino
2388*6ea1f93eSDaniel Fojt'er'
2389*6ea1f93eSDaniel Fojt'e2'
2390008e37b6SJohn Marino     Edit a copy of the right version, then copy the result to the
2391008e37b6SJohn Marino     output.
2392008e37b6SJohn Marino
2393*6ea1f93eSDaniel Fojt'l'
2394*6ea1f93eSDaniel Fojt'1'
2395008e37b6SJohn Marino     Copy the left version to the output.
2396008e37b6SJohn Marino
2397*6ea1f93eSDaniel Fojt'q'
2398008e37b6SJohn Marino     Quit.
2399008e37b6SJohn Marino
2400*6ea1f93eSDaniel Fojt'r'
2401*6ea1f93eSDaniel Fojt'2'
2402008e37b6SJohn Marino     Copy the right version to the output.
2403008e37b6SJohn Marino
2404*6ea1f93eSDaniel Fojt's'
2405008e37b6SJohn Marino     Silently copy common lines.
2406008e37b6SJohn Marino
2407*6ea1f93eSDaniel Fojt'v'
2408008e37b6SJohn Marino     Verbosely copy common lines.  This is the default.
2409008e37b6SJohn Marino
2410*6ea1f93eSDaniel Fojt   The text editor invoked is specified by the 'EDITOR' environment
2411008e37b6SJohn Marinovariable if it is set.  The default is system-dependent.
2412008e37b6SJohn Marino
2413008e37b6SJohn Marino
2414*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Merging with patch,  Next: Making Patches,  Prev: Interactive Merging,  Up: Top
2415008e37b6SJohn Marino
2416*6ea1f93eSDaniel Fojt10 Merging with 'patch'
2417008e37b6SJohn Marino***********************
2418008e37b6SJohn Marino
2419*6ea1f93eSDaniel Fojt'patch' takes comparison output produced by 'diff' and applies the
2420*6ea1f93eSDaniel Fojtdifferences to a copy of the original file, producing a patched version.
2421*6ea1f93eSDaniel FojtWith 'patch', you can distribute just the changes to a set of files
2422*6ea1f93eSDaniel Fojtinstead of distributing the entire file set; your correspondents can
2423*6ea1f93eSDaniel Fojtapply 'patch' to update their copy of the files with your changes.
2424*6ea1f93eSDaniel Fojt'patch' automatically determines the diff format, skips any leading or
2425*6ea1f93eSDaniel Fojttrailing headers, and uses the headers to determine which file to patch.
2426*6ea1f93eSDaniel FojtThis lets your correspondents feed a mail message containing a
2427*6ea1f93eSDaniel Fojtdifference listing directly to 'patch'.
2428008e37b6SJohn Marino
2429*6ea1f93eSDaniel Fojt   'patch' detects and warns about common problems like forward patches.
2430*6ea1f93eSDaniel FojtIt saves any patches that it could not apply.  It can also maintain a
2431*6ea1f93eSDaniel Fojt'patchlevel.h' file to ensure that your correspondents apply diffs in
2432*6ea1f93eSDaniel Fojtthe proper order.
2433008e37b6SJohn Marino
2434*6ea1f93eSDaniel Fojt   'patch' accepts a series of diffs in its standard input, usually
2435008e37b6SJohn Marinoseparated by headers that specify which file to patch.  It applies
2436*6ea1f93eSDaniel Fojt'diff' hunks (*note Hunks::) one by one.  If a hunk does not exactly
2437*6ea1f93eSDaniel Fojtmatch the original file, 'patch' uses heuristics to try to patch the
2438*6ea1f93eSDaniel Fojtfile as well as it can.  If no approximate match can be found, 'patch'
2439*6ea1f93eSDaniel Fojtrejects the hunk and skips to the next hunk.  'patch' normally replaces
2440008e37b6SJohn Marinoeach file F with its new version, putting reject hunks (if any) into
2441*6ea1f93eSDaniel Fojt'F.rej'.
2442008e37b6SJohn Marino
2443008e37b6SJohn Marino   *Note Invoking patch::, for detailed information on the options to
2444*6ea1f93eSDaniel Fojt'patch'.
2445008e37b6SJohn Marino
2446008e37b6SJohn Marino* Menu:
2447008e37b6SJohn Marino
2448*6ea1f93eSDaniel Fojt* patch Input::            Selecting the type of 'patch' input.
2449008e37b6SJohn Marino* Revision Control::       Getting files from RCS, SCCS, etc.
2450008e37b6SJohn Marino* Imperfect::              Dealing with imperfect patches.
2451008e37b6SJohn Marino* Creating and Removing::  Creating and removing files with a patch.
2452*6ea1f93eSDaniel Fojt* Patching Timestamps::   Updating timestamps on patched files.
2453008e37b6SJohn Marino* Multiple Patches::       Handling multiple patches in a file.
2454008e37b6SJohn Marino* patch Directories::      Changing directory and stripping directories.
2455008e37b6SJohn Marino* Backups::                Whether backup files are made.
2456008e37b6SJohn Marino* Backup Names::           Backup file names.
2457008e37b6SJohn Marino* Reject Names::           Reject file names.
2458*6ea1f93eSDaniel Fojt* patch Messages::         Messages and questions 'patch' can produce.
2459008e37b6SJohn Marino* patch and POSIX::        Conformance to the POSIX standard.
2460*6ea1f93eSDaniel Fojt* patch and Tradition::    GNU versus traditional 'patch'.
2461008e37b6SJohn Marino
2462008e37b6SJohn Marino
2463*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch Input,  Next: Revision Control,  Up: Merging with patch
2464008e37b6SJohn Marino
2465*6ea1f93eSDaniel Fojt10.1 Selecting the 'patch' Input Format
2466008e37b6SJohn Marino=======================================
2467008e37b6SJohn Marino
2468*6ea1f93eSDaniel Fojt'patch' normally determines which 'diff' format the patch file uses by
2469008e37b6SJohn Marinoexamining its contents.  For patch files that contain particularly
2470008e37b6SJohn Marinoconfusing leading text, you might need to use one of the following
2471*6ea1f93eSDaniel Fojtoptions to force 'patch' to interpret the patch file as a certain format
2472*6ea1f93eSDaniel Fojtof diff.  The output formats listed here are the only ones that 'patch'
2473*6ea1f93eSDaniel Fojtcan understand.
2474008e37b6SJohn Marino
2475*6ea1f93eSDaniel Fojt'-c'
2476*6ea1f93eSDaniel Fojt'--context'
2477008e37b6SJohn Marino     context diff.
2478008e37b6SJohn Marino
2479*6ea1f93eSDaniel Fojt'-e'
2480*6ea1f93eSDaniel Fojt'--ed'
2481*6ea1f93eSDaniel Fojt     'ed' script.
2482008e37b6SJohn Marino
2483*6ea1f93eSDaniel Fojt'-n'
2484*6ea1f93eSDaniel Fojt'--normal'
2485008e37b6SJohn Marino     normal diff.
2486008e37b6SJohn Marino
2487*6ea1f93eSDaniel Fojt'-u'
2488*6ea1f93eSDaniel Fojt'--unified'
2489008e37b6SJohn Marino     unified diff.
2490008e37b6SJohn Marino
2491008e37b6SJohn Marino
2492*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Revision Control,  Next: Imperfect,  Prev: patch Input,  Up: Merging with patch
2493008e37b6SJohn Marino
2494008e37b6SJohn Marino10.2 Revision Control
2495008e37b6SJohn Marino=====================
2496008e37b6SJohn Marino
2497*6ea1f93eSDaniel FojtIf a nonexistent input file is under a revision control system supported
2498*6ea1f93eSDaniel Fojtby 'patch', 'patch' normally asks the user whether to get (or check out)
2499*6ea1f93eSDaniel Fojtthe file from the revision control system.  Patch currently supports
2500*6ea1f93eSDaniel FojtRCS, ClearCase and SCCS. Under RCS and SCCS, 'patch' also asks when the
2501*6ea1f93eSDaniel Fojtinput file is read-only and matches the default version in the revision
2502*6ea1f93eSDaniel Fojtcontrol system.
2503008e37b6SJohn Marino
2504*6ea1f93eSDaniel Fojt   The '--get=NUM' ('-g NUM') option affects access to files under
2505*6ea1f93eSDaniel Fojtsupported revision control systems.  If NUM is positive, 'patch' gets
2506*6ea1f93eSDaniel Fojtthe file without asking the user; if zero, 'patch' neither asks the user
2507*6ea1f93eSDaniel Fojtnor gets the file; and if negative, 'patch' asks the user before getting
2508*6ea1f93eSDaniel Fojtthe file.  The default value of NUM is given by the value of the
2509*6ea1f93eSDaniel Fojt'PATCH_GET' environment variable if it is set; if not, the default value
2510*6ea1f93eSDaniel Fojtis zero if 'patch' is conforming to POSIX, negative otherwise.  *Note
2511*6ea1f93eSDaniel Fojtpatch and POSIX::.
2512008e37b6SJohn Marino
2513008e37b6SJohn Marino   The choice of revision control system is unaffected by the
2514*6ea1f93eSDaniel Fojt'VERSION_CONTROL' environment variable (*note Backup Names::).
2515008e37b6SJohn Marino
2516008e37b6SJohn Marino
2517*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Imperfect,  Next: Creating and Removing,  Prev: Revision Control,  Up: Merging with patch
2518008e37b6SJohn Marino
2519008e37b6SJohn Marino10.3 Applying Imperfect Patches
2520008e37b6SJohn Marino===============================
2521008e37b6SJohn Marino
2522*6ea1f93eSDaniel Fojt'patch' tries to skip any leading text in the patch file, apply the
2523*6ea1f93eSDaniel Fojtdiff, and then skip any trailing text.  Thus you can feed a mail message
2524*6ea1f93eSDaniel Fojtdirectly to 'patch', and it should work.  If the entire diff is indented
2525*6ea1f93eSDaniel Fojtby a constant amount of white space, 'patch' automatically ignores the
2526*6ea1f93eSDaniel Fojtindentation.  If a context diff contains trailing carriage return on
2527*6ea1f93eSDaniel Fojteach line, 'patch' automatically ignores the carriage return.  If a
2528*6ea1f93eSDaniel Fojtcontext diff has been encapsulated by prepending '- ' to lines beginning
2529*6ea1f93eSDaniel Fojtwith '-' as per Internet RFC 934
2530*6ea1f93eSDaniel Fojt(ftp://ftp.isi.edu/in-notes/rfc934.txt), 'patch' automatically
2531008e37b6SJohn Marinounencapsulates the input.
2532008e37b6SJohn Marino
2533008e37b6SJohn Marino   However, certain other types of imperfect input require user
2534008e37b6SJohn Marinointervention or testing.
2535008e37b6SJohn Marino
2536008e37b6SJohn Marino* Menu:
2537008e37b6SJohn Marino
2538008e37b6SJohn Marino* Changed White Space:: When tabs and spaces don't match exactly.
2539008e37b6SJohn Marino* Reversed Patches::    Applying reversed patches correctly.
2540*6ea1f93eSDaniel Fojt* Inexact::             Helping 'patch' find close matches.
2541*6ea1f93eSDaniel Fojt* Dry Runs::            Predicting what 'patch' will do.
2542008e37b6SJohn Marino
2543008e37b6SJohn Marino
2544*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Changed White Space,  Next: Reversed Patches,  Up: Imperfect
2545008e37b6SJohn Marino
2546008e37b6SJohn Marino10.3.1 Applying Patches with Changed White Space
2547008e37b6SJohn Marino------------------------------------------------
2548008e37b6SJohn Marino
2549008e37b6SJohn MarinoSometimes mailers, editors, or other programs change spaces into tabs,
2550008e37b6SJohn Marinoor vice versa.  If this happens to a patch file or an input file, the
2551*6ea1f93eSDaniel Fojtfiles might look the same, but 'patch' will not be able to match them
2552*6ea1f93eSDaniel Fojtproperly.  If this problem occurs, use the '-l' or
2553*6ea1f93eSDaniel Fojt'--ignore-white-space' option, which makes 'patch' compare blank
2554008e37b6SJohn Marinocharacters (i.e. spaces and tabs) loosely so that any nonempty sequence
2555008e37b6SJohn Marinoof blanks in the patch file matches any nonempty sequence of blanks in
2556008e37b6SJohn Marinothe input files.  Non-blank characters must still match exactly.  Each
2557008e37b6SJohn Marinoline of the context must still match a line in the input file.
2558008e37b6SJohn Marino
2559008e37b6SJohn Marino
2560*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Reversed Patches,  Next: Inexact,  Prev: Changed White Space,  Up: Imperfect
2561008e37b6SJohn Marino
2562008e37b6SJohn Marino10.3.2 Applying Reversed Patches
2563008e37b6SJohn Marino--------------------------------
2564008e37b6SJohn Marino
2565*6ea1f93eSDaniel FojtSometimes people run 'diff' with the new file first instead of second.
2566008e37b6SJohn MarinoThis creates a diff that is "reversed".  To apply such patches, give
2567*6ea1f93eSDaniel Fojt'patch' the '--reverse' ('-R') option.  'patch' then attempts to swap
2568008e37b6SJohn Marinoeach hunk around before applying it.  Rejects come out in the swapped
2569008e37b6SJohn Marinoformat.
2570008e37b6SJohn Marino
2571*6ea1f93eSDaniel Fojt   Often 'patch' can guess that the patch is reversed.  If the first
2572*6ea1f93eSDaniel Fojthunk of a patch fails, 'patch' reverses the hunk to see if it can apply
2573*6ea1f93eSDaniel Fojtit that way.  If it can, 'patch' asks you if you want to have the '-R'
2574*6ea1f93eSDaniel Fojtoption set; if it can't, 'patch' continues to apply the patch normally.
2575008e37b6SJohn MarinoThis method cannot detect a reversed patch if it is a normal diff and
2576008e37b6SJohn Marinothe first command is an append (which should have been a delete) since
2577008e37b6SJohn Marinoappends always succeed, because a null context matches anywhere.  But
2578008e37b6SJohn Marinomost patches add or change lines rather than delete them, so most
2579*6ea1f93eSDaniel Fojtreversed normal diffs begin with a delete, which fails, and 'patch'
2580008e37b6SJohn Marinonotices.
2581008e37b6SJohn Marino
2582*6ea1f93eSDaniel Fojt   If you apply a patch that you have already applied, 'patch' thinks it
2583*6ea1f93eSDaniel Fojtis a reversed patch and offers to un-apply the patch.  This could be
2584008e37b6SJohn Marinoconstrued as a feature.  If you did this inadvertently and you don't
2585*6ea1f93eSDaniel Fojtwant to un-apply the patch, just answer 'n' to this offer and to the
2586*6ea1f93eSDaniel Fojtsubsequent "apply anyway" question--or type 'C-c' to kill the 'patch'
2587008e37b6SJohn Marinoprocess.
2588008e37b6SJohn Marino
2589008e37b6SJohn Marino
2590*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Inexact,  Next: Dry Runs,  Prev: Reversed Patches,  Up: Imperfect
2591008e37b6SJohn Marino
2592*6ea1f93eSDaniel Fojt10.3.3 Helping 'patch' Find Inexact Matches
2593008e37b6SJohn Marino-------------------------------------------
2594008e37b6SJohn Marino
2595*6ea1f93eSDaniel FojtFor context diffs, and to a lesser extent normal diffs, 'patch' can
2596008e37b6SJohn Marinodetect when the line numbers mentioned in the patch are incorrect, and
2597008e37b6SJohn Marinoit attempts to find the correct place to apply each hunk of the patch.
2598008e37b6SJohn MarinoAs a first guess, it takes the line number mentioned in the hunk, plus
2599008e37b6SJohn Marinoor minus any offset used in applying the previous hunk.  If that is not
2600*6ea1f93eSDaniel Fojtthe correct place, 'patch' scans both forward and backward for a set of
2601008e37b6SJohn Marinolines matching the context given in the hunk.
2602008e37b6SJohn Marino
2603*6ea1f93eSDaniel Fojt   First 'patch' looks for a place where all lines of the context match.
2604*6ea1f93eSDaniel FojtIf it cannot find such a place, and it is reading a context or unified
2605*6ea1f93eSDaniel Fojtdiff, and the maximum fuzz factor is set to 1 or more, then 'patch'
2606*6ea1f93eSDaniel Fojtmakes another scan, ignoring the first and last line of context.  If
2607*6ea1f93eSDaniel Fojtthat fails, and the maximum fuzz factor is set to 2 or more, it makes
2608*6ea1f93eSDaniel Fojtanother scan, ignoring the first two and last two lines of context are
2609*6ea1f93eSDaniel Fojtignored.  It continues similarly if the maximum fuzz factor is larger.
2610008e37b6SJohn Marino
2611*6ea1f93eSDaniel Fojt   The '--fuzz=LINES' ('-F LINES') option sets the maximum fuzz factor
2612008e37b6SJohn Marinoto LINES.  This option only applies to context and unified diffs; it
2613*6ea1f93eSDaniel Fojtignores up to LINES lines while looking for the place to install a hunk.
2614*6ea1f93eSDaniel FojtNote that a larger fuzz factor increases the odds of making a faulty
2615*6ea1f93eSDaniel Fojtpatch.  The default fuzz factor is 2; there is no point to setting it to
2616*6ea1f93eSDaniel Fojtmore than the number of lines of context in the diff, ordinarily 3.
2617008e37b6SJohn Marino
2618*6ea1f93eSDaniel Fojt   If 'patch' cannot find a place to install a hunk of the patch, it
2619008e37b6SJohn Marinowrites the hunk out to a reject file (*note Reject Names::, for
2620008e37b6SJohn Marinoinformation on how reject files are named).  It writes out rejected
2621008e37b6SJohn Marinohunks in context format no matter what form the input patch is in.  If
2622*6ea1f93eSDaniel Fojtthe input is a normal or 'ed' diff, many of the contexts are simply
2623*6ea1f93eSDaniel Fojtnull.  The line numbers on the hunks in the reject file may be different
2624*6ea1f93eSDaniel Fojtfrom those in the patch file: they show the approximate location where
2625*6ea1f93eSDaniel Fojt'patch' thinks the failed hunks belong in the new file rather than in
2626*6ea1f93eSDaniel Fojtthe old one.
2627008e37b6SJohn Marino
2628*6ea1f93eSDaniel Fojt   If the '--verbose' option is given, then as it completes each hunk
2629*6ea1f93eSDaniel Fojt'patch' tells you whether the hunk succeeded or failed, and if it
2630*6ea1f93eSDaniel Fojtfailed, on which line (in the new file) 'patch' thinks the hunk should
2631*6ea1f93eSDaniel Fojtgo.  If this is different from the line number specified in the diff, it
2632*6ea1f93eSDaniel Fojttells you the offset.  A single large offset _may_ indicate that 'patch'
2633*6ea1f93eSDaniel Fojtinstalled a hunk in the wrong place.  'patch' also tells you if it used
2634*6ea1f93eSDaniel Fojta fuzz factor to make the match, in which case you should also be
2635*6ea1f93eSDaniel Fojtslightly suspicious.
2636008e37b6SJohn Marino
2637*6ea1f93eSDaniel Fojt   'patch' cannot tell if the line numbers are off in an 'ed' script,
2638008e37b6SJohn Marinoand can only detect wrong line numbers in a normal diff when it finds a
2639008e37b6SJohn Marinochange or delete command.  It may have the same problem with a context
2640*6ea1f93eSDaniel Fojtdiff using a fuzz factor equal to or greater than the number of lines of
2641*6ea1f93eSDaniel Fojtcontext shown in the diff (typically 3).  In these cases, you should
2642008e37b6SJohn Marinoprobably look at a context diff between your original and patched input
2643008e37b6SJohn Marinofiles to see if the changes make sense.  Compiling without errors is a
2644008e37b6SJohn Marinopretty good indication that the patch worked, but not a guarantee.
2645008e37b6SJohn Marino
2646008e37b6SJohn Marino   A patch against an empty file applies to a nonexistent file, and vice
2647008e37b6SJohn Marinoversa.  *Note Creating and Removing::.
2648008e37b6SJohn Marino
2649*6ea1f93eSDaniel Fojt   'patch' usually produces the correct results, even when it must make
2650008e37b6SJohn Marinomany guesses.  However, the results are guaranteed only when the patch
2651008e37b6SJohn Marinois applied to an exact copy of the file that the patch was generated
2652008e37b6SJohn Marinofrom.
2653008e37b6SJohn Marino
2654008e37b6SJohn Marino
2655*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Dry Runs,  Prev: Inexact,  Up: Imperfect
2656008e37b6SJohn Marino
2657*6ea1f93eSDaniel Fojt10.3.4 Predicting what 'patch' will do
2658008e37b6SJohn Marino--------------------------------------
2659008e37b6SJohn Marino
2660*6ea1f93eSDaniel FojtIt may not be obvious in advance what 'patch' will do with a complicated
2661*6ea1f93eSDaniel Fojtor poorly formatted patch.  If you are concerned that the input might
2662*6ea1f93eSDaniel Fojtcause 'patch' to modify the wrong files, you can use the '--dry-run'
2663*6ea1f93eSDaniel Fojtoption, which causes 'patch' to print the results of applying patches
2664*6ea1f93eSDaniel Fojtwithout actually changing any files.  You can then inspect the
2665*6ea1f93eSDaniel Fojtdiagnostics generated by the dry run to see whether 'patch' will modify
2666*6ea1f93eSDaniel Fojtthe files that you expect.  If the patch does not do what you want, you
2667*6ea1f93eSDaniel Fojtcan modify the patch (or the other options to 'patch') and try another
2668*6ea1f93eSDaniel Fojtdry run.  Once you are satisfied with the proposed patch you can apply
2669*6ea1f93eSDaniel Fojtit by invoking 'patch' as before, but this time without the '--dry-run'
2670*6ea1f93eSDaniel Fojtoption.
2671008e37b6SJohn Marino
2672008e37b6SJohn Marino
2673*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Creating and Removing,  Next: Patching Timestamps,  Prev: Imperfect,  Up: Merging with patch
2674008e37b6SJohn Marino
2675008e37b6SJohn Marino10.4 Creating and Removing Files
2676008e37b6SJohn Marino================================
2677008e37b6SJohn Marino
2678008e37b6SJohn MarinoSometimes when comparing two directories, a file may exist in one
2679*6ea1f93eSDaniel Fojtdirectory but not the other.  If you give 'diff' the '--new-file' ('-N')
2680*6ea1f93eSDaniel Fojtoption, or if you supply an old or new file that is named '/dev/null' or
2681*6ea1f93eSDaniel Fojtis empty and is dated the Epoch (1970-01-01 00:00:00 UTC), 'diff'
2682*6ea1f93eSDaniel Fojtoutputs a patch that adds or deletes the contents of this file.  When
2683*6ea1f93eSDaniel Fojtgiven such a patch, 'patch' normally creates a new file or removes the
2684*6ea1f93eSDaniel Fojtold file.  However, when conforming to POSIX (*note patch and POSIX::),
2685*6ea1f93eSDaniel Fojt'patch' does not remove the old file, but leaves it empty.  The
2686*6ea1f93eSDaniel Fojt'--remove-empty-files' ('-E') option causes 'patch' to remove output
2687*6ea1f93eSDaniel Fojtfiles that are empty after applying a patch, even if the patch does not
2688*6ea1f93eSDaniel Fojtappear to be one that removed the file.
2689008e37b6SJohn Marino
2690*6ea1f93eSDaniel Fojt   If the patch appears to create a file that already exists, 'patch'
2691008e37b6SJohn Marinoasks for confirmation before applying the patch.
2692008e37b6SJohn Marino
2693008e37b6SJohn Marino
2694*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Patching Timestamps,  Next: Multiple Patches,  Prev: Creating and Removing,  Up: Merging with patch
2695008e37b6SJohn Marino
2696*6ea1f93eSDaniel Fojt10.5 Updating Timestamps on Patched Files
2697*6ea1f93eSDaniel Fojt=========================================
2698008e37b6SJohn Marino
2699*6ea1f93eSDaniel FojtWhen 'patch' updates a file, it normally sets the file's last-modified
2700*6ea1f93eSDaniel Fojttimestamp to the current time of day.  If you are using 'patch' to track
2701*6ea1f93eSDaniel Fojta software distribution, this can cause 'make' to incorrectly conclude
2702*6ea1f93eSDaniel Fojtthat a patched file is out of date.  For example, if 'syntax.c' depends
2703*6ea1f93eSDaniel Fojton 'syntax.y', and 'patch' updates 'syntax.c' and then 'syntax.y', then
2704*6ea1f93eSDaniel Fojt'syntax.c' will normally appear to be out of date with respect to
2705*6ea1f93eSDaniel Fojt'syntax.y' even though its contents are actually up to date.
2706008e37b6SJohn Marino
2707*6ea1f93eSDaniel Fojt   The '--set-utc' ('-Z') option causes 'patch' to set a patched file's
2708008e37b6SJohn Marinomodification and access times to the timestamps given in context diff
2709008e37b6SJohn Marinoheaders.  If the context diff headers do not specify a time zone, they
2710008e37b6SJohn Marinoare assumed to use Coordinated Universal Time (UTC, often known as GMT).
2711008e37b6SJohn Marino
2712*6ea1f93eSDaniel Fojt   The '--set-time' ('-T') option acts like '-Z' or '--set-utc', except
2713*6ea1f93eSDaniel Fojtthat it assumes that the context diff headers' timestamps use local time
2714*6ea1f93eSDaniel Fojtinstead of UTC. This option is not recommended, because patches using
2715*6ea1f93eSDaniel Fojtlocal time cannot easily be used by people in other time zones, and
2716*6ea1f93eSDaniel Fojtbecause local timestamps are ambiguous when local clocks move backwards
2717*6ea1f93eSDaniel Fojtduring daylight-saving time adjustments.  If the context diff headers
2718*6ea1f93eSDaniel Fojtspecify a time zone, this option is equivalent to '--set-utc' ('-Z').
2719008e37b6SJohn Marino
2720*6ea1f93eSDaniel Fojt   'patch' normally refrains from setting a file's timestamps if the
2721*6ea1f93eSDaniel Fojtfile's original last-modified timestamp does not match the time given in
2722*6ea1f93eSDaniel Fojtthe diff header, of if the file's contents do not exactly match the
2723*6ea1f93eSDaniel Fojtpatch.  However, if the '--force' ('-f') option is given, the file's
2724008e37b6SJohn Marinotimestamps are set regardless.
2725008e37b6SJohn Marino
2726*6ea1f93eSDaniel Fojt   Due to the limitations of the current 'diff' format, 'patch' cannot
2727*6ea1f93eSDaniel Fojtupdate the times of files whose contents have not changed.  Also, if you
2728*6ea1f93eSDaniel Fojtset file timestamps to values other than the current time of day, you
2729*6ea1f93eSDaniel Fojtshould also remove (e.g., with 'make clean') all files that depend on
2730*6ea1f93eSDaniel Fojtthe patched files, so that later invocations of 'make' do not get
2731008e37b6SJohn Marinoconfused by the patched files' times.
2732008e37b6SJohn Marino
2733008e37b6SJohn Marino
2734*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Multiple Patches,  Next: patch Directories,  Prev: Patching Timestamps,  Up: Merging with patch
2735008e37b6SJohn Marino
2736008e37b6SJohn Marino10.6 Multiple Patches in a File
2737008e37b6SJohn Marino===============================
2738008e37b6SJohn Marino
2739008e37b6SJohn MarinoIf the patch file contains more than one patch, and if you do not
2740*6ea1f93eSDaniel Fojtspecify an input file on the command line, 'patch' tries to apply each
2741008e37b6SJohn Marinopatch as if they came from separate patch files.  This means that it
2742008e37b6SJohn Marinodetermines the name of the file to patch for each patch, and that it
2743008e37b6SJohn Marinoexamines the leading text before each patch for file names and
2744008e37b6SJohn Marinoprerequisite revision level (*note Making Patches::, for more on that
2745008e37b6SJohn Marinotopic).
2746008e37b6SJohn Marino
2747*6ea1f93eSDaniel Fojt   'patch' uses the following rules to intuit a file name from the
2748*6ea1f93eSDaniel Fojtleading text before a patch.  First, 'patch' takes an ordered list of
2749008e37b6SJohn Marinocandidate file names as follows:
2750008e37b6SJohn Marino
2751*6ea1f93eSDaniel Fojt   * If the header is that of a context diff, 'patch' takes the old and
2752008e37b6SJohn Marino     new file names in the header.  A name is ignored if it does not
2753*6ea1f93eSDaniel Fojt     have enough slashes to satisfy the '-pNUM' or '--strip=NUM' option.
2754*6ea1f93eSDaniel Fojt     The name '/dev/null' is also ignored.
2755008e37b6SJohn Marino
2756*6ea1f93eSDaniel Fojt   * If there is an 'Index:' line in the leading garbage and if either
2757*6ea1f93eSDaniel Fojt     the old and new names are both absent or if 'patch' is conforming
2758*6ea1f93eSDaniel Fojt     to POSIX, 'patch' takes the name in the 'Index:' line.
2759008e37b6SJohn Marino
2760008e37b6SJohn Marino   * For the purpose of the following rules, the candidate file names
2761008e37b6SJohn Marino     are considered to be in the order (old, new, index), regardless of
2762008e37b6SJohn Marino     the order that they appear in the header.
2763008e37b6SJohn Marino
2764*6ea1f93eSDaniel FojtThen 'patch' selects a file name from the candidate list as follows:
2765008e37b6SJohn Marino
2766*6ea1f93eSDaniel Fojt   * If some of the named files exist, 'patch' selects the first name if
2767*6ea1f93eSDaniel Fojt     conforming to POSIX, and the best name otherwise.
2768008e37b6SJohn Marino
2769*6ea1f93eSDaniel Fojt   * If 'patch' is not ignoring RCS, ClearCase, and SCCS (*note Revision
2770*6ea1f93eSDaniel Fojt     Control::), and no named files exist but an RCS, ClearCase, or SCCS
2771*6ea1f93eSDaniel Fojt     master is found, 'patch' selects the first named file with an RCS,
2772*6ea1f93eSDaniel Fojt     ClearCase, or SCCS master.
2773008e37b6SJohn Marino
2774008e37b6SJohn Marino   * If no named files exist, no RCS, ClearCase, or SCCS master was
2775*6ea1f93eSDaniel Fojt     found, some names are given, 'patch' is not conforming to POSIX,
2776*6ea1f93eSDaniel Fojt     and the patch appears to create a file, 'patch' selects the best
2777008e37b6SJohn Marino     name requiring the creation of the fewest directories.
2778008e37b6SJohn Marino
2779008e37b6SJohn Marino   * If no file name results from the above heuristics, you are asked
2780*6ea1f93eSDaniel Fojt     for the name of the file to patch, and 'patch' selects that name.
2781008e37b6SJohn Marino
2782*6ea1f93eSDaniel Fojt   To determine the "best" of a nonempty list of file names, 'patch'
2783008e37b6SJohn Marinofirst takes all the names with the fewest path name components; of
2784*6ea1f93eSDaniel Fojtthose, it then takes all the names with the shortest basename; of those,
2785*6ea1f93eSDaniel Fojtit then takes all the shortest names; finally, it takes the first
2786*6ea1f93eSDaniel Fojtremaining name.
2787008e37b6SJohn Marino
2788*6ea1f93eSDaniel Fojt   *Note patch and POSIX::, to see whether 'patch' is conforming to
2789008e37b6SJohn MarinoPOSIX.
2790008e37b6SJohn Marino
2791008e37b6SJohn Marino
2792*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch Directories,  Next: Backups,  Prev: Multiple Patches,  Up: Merging with patch
2793008e37b6SJohn Marino
2794008e37b6SJohn Marino10.7 Applying Patches in Other Directories
2795008e37b6SJohn Marino==========================================
2796008e37b6SJohn Marino
2797*6ea1f93eSDaniel FojtThe '--directory=DIRECTORY' ('-d DIRECTORY') option to 'patch' makes
2798008e37b6SJohn Marinodirectory DIRECTORY the current directory for interpreting both file
2799008e37b6SJohn Marinonames in the patch file, and file names given as arguments to other
2800*6ea1f93eSDaniel Fojtoptions (such as '-B' and '-o').  For example, while in a mail reading
2801*6ea1f93eSDaniel Fojtprogram, you can patch a file in the '/usr/src/emacs' directory directly
2802*6ea1f93eSDaniel Fojtfrom a message containing the patch like this:
2803008e37b6SJohn Marino
2804008e37b6SJohn Marino     | patch -d /usr/src/emacs
2805008e37b6SJohn Marino
2806008e37b6SJohn Marino   Sometimes the file names given in a patch contain leading
2807008e37b6SJohn Marinodirectories, but you keep your files in a directory different from the
2808008e37b6SJohn Marinoone given in the patch.  In those cases, you can use the
2809*6ea1f93eSDaniel Fojt'--strip=NUMBER' ('-pNUMBER') option to set the file name strip count to
2810*6ea1f93eSDaniel FojtNUMBER.  The strip count tells 'patch' how many slashes, along with the
2811*6ea1f93eSDaniel Fojtdirectory names between them, to strip from the front of file names.  A
2812*6ea1f93eSDaniel Fojtsequence of one or more adjacent slashes is counted as a single slash.
2813*6ea1f93eSDaniel FojtBy default, 'patch' strips off all leading directories, leaving just the
2814*6ea1f93eSDaniel Fojtbase file names.
2815008e37b6SJohn Marino
2816008e37b6SJohn Marino   For example, suppose the file name in the patch file is
2817*6ea1f93eSDaniel Fojt'/gnu/src/emacs/etc/NEWS'.  Using '-p0' gives the entire file name
2818*6ea1f93eSDaniel Fojtunmodified, '-p1' gives 'gnu/src/emacs/etc/NEWS' (no leading slash),
2819*6ea1f93eSDaniel Fojt'-p4' gives 'etc/NEWS', and not specifying '-p' at all gives 'NEWS'.
2820008e37b6SJohn Marino
2821*6ea1f93eSDaniel Fojt   'patch' looks for each file (after any slashes have been stripped) in
2822*6ea1f93eSDaniel Fojtthe current directory, or if you used the '-d DIRECTORY' option, in that
2823*6ea1f93eSDaniel Fojtdirectory.
2824008e37b6SJohn Marino
2825008e37b6SJohn Marino
2826*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Backups,  Next: Backup Names,  Prev: patch Directories,  Up: Merging with patch
2827008e37b6SJohn Marino
2828008e37b6SJohn Marino10.8 Backup Files
2829008e37b6SJohn Marino=================
2830008e37b6SJohn Marino
2831*6ea1f93eSDaniel FojtNormally, 'patch' creates a backup file if the patch does not exactly
2832008e37b6SJohn Marinomatch the original input file, because in that case the original data
2833*6ea1f93eSDaniel Fojtmight not be recovered if you undo the patch with 'patch -R' (*note
2834*6ea1f93eSDaniel FojtReversed Patches::).  However, when conforming to POSIX, 'patch' does
2835008e37b6SJohn Marinonot create backup files by default.  *Note patch and POSIX::.
2836008e37b6SJohn Marino
2837*6ea1f93eSDaniel Fojt   The '--backup' ('-b') option causes 'patch' to make a backup file
2838008e37b6SJohn Marinoregardless of whether the patch matches the original input.  The
2839*6ea1f93eSDaniel Fojt'--backup-if-mismatch' option causes 'patch' to create backup files for
2840008e37b6SJohn Marinomismatches files; this is the default when not conforming to POSIX. The
2841*6ea1f93eSDaniel Fojt'--no-backup-if-mismatch' option causes 'patch' to not create backup
2842008e37b6SJohn Marinofiles, even for mismatched patches; this is the default when conforming
2843008e37b6SJohn Marinoto POSIX.
2844008e37b6SJohn Marino
2845008e37b6SJohn Marino   When backing up a file that does not exist, an empty, unreadable
2846008e37b6SJohn Marinobackup file is created as a placeholder to represent the nonexistent
2847008e37b6SJohn Marinofile.
2848008e37b6SJohn Marino
2849008e37b6SJohn Marino
2850*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Backup Names,  Next: Reject Names,  Prev: Backups,  Up: Merging with patch
2851008e37b6SJohn Marino
2852008e37b6SJohn Marino10.9 Backup File Names
2853008e37b6SJohn Marino======================
2854008e37b6SJohn Marino
2855*6ea1f93eSDaniel FojtNormally, 'patch' renames an original input file into a backup file by
2856*6ea1f93eSDaniel Fojtappending to its name the extension '.orig', or '~' if using '.orig'
2857*6ea1f93eSDaniel Fojtwould make the backup file name too long.(1)  The '-z BACKUP-SUFFIX' or
2858*6ea1f93eSDaniel Fojt'--suffix=BACKUP-SUFFIX' option causes 'patch' to use BACKUP-SUFFIX as
2859008e37b6SJohn Marinothe backup extension instead.
2860008e37b6SJohn Marino
2861008e37b6SJohn Marino   Alternately, you can specify the extension for backup files with the
2862*6ea1f93eSDaniel Fojt'SIMPLE_BACKUP_SUFFIX' environment variable, which the options override.
2863008e37b6SJohn Marino
2864*6ea1f93eSDaniel Fojt   'patch' can also create numbered backup files the way GNU Emacs does.
2865*6ea1f93eSDaniel FojtWith this method, instead of having a single backup of each file,
2866*6ea1f93eSDaniel Fojt'patch' makes a new backup file name each time it patches a file.  For
2867*6ea1f93eSDaniel Fojtexample, the backups of a file named 'sink' would be called,
2868*6ea1f93eSDaniel Fojtsuccessively, 'sink.~1~', 'sink.~2~', 'sink.~3~', etc.
2869008e37b6SJohn Marino
2870*6ea1f93eSDaniel Fojt   The '-V BACKUP-STYLE' or '--version-control=BACKUP-STYLE' option
2871008e37b6SJohn Marinotakes as an argument a method for creating backup file names.  You can
2872*6ea1f93eSDaniel Fojtalternately control the type of backups that 'patch' makes with the
2873*6ea1f93eSDaniel Fojt'PATCH_VERSION_CONTROL' environment variable, which the '-V' option
2874*6ea1f93eSDaniel Fojtoverrides.  If 'PATCH_VERSION_CONTROL' is not set, the 'VERSION_CONTROL'
2875*6ea1f93eSDaniel Fojtenvironment variable is used instead.  Please note that these options
2876*6ea1f93eSDaniel Fojtand variables control backup file names; they do not affect the choice
2877*6ea1f93eSDaniel Fojtof revision control system (*note Revision Control::).
2878008e37b6SJohn Marino
2879008e37b6SJohn Marino   The values of these environment variables and the argument to the
2880*6ea1f93eSDaniel Fojt'-V' option are like the GNU Emacs 'version-control' variable (*note
2881*6ea1f93eSDaniel Fojt(emacs)Backup Names::, for more information on backup versions in
2882*6ea1f93eSDaniel FojtEmacs).  They also recognize synonyms that are more descriptive.  The
2883*6ea1f93eSDaniel Fojtvalid values are listed below; unique abbreviations are acceptable.
2884008e37b6SJohn Marino
2885*6ea1f93eSDaniel Fojt't'
2886*6ea1f93eSDaniel Fojt'numbered'
2887008e37b6SJohn Marino     Always make numbered backups.
2888008e37b6SJohn Marino
2889*6ea1f93eSDaniel Fojt'nil'
2890*6ea1f93eSDaniel Fojt'existing'
2891008e37b6SJohn Marino     Make numbered backups of files that already have them, simple
2892008e37b6SJohn Marino     backups of the others.  This is the default.
2893008e37b6SJohn Marino
2894*6ea1f93eSDaniel Fojt'never'
2895*6ea1f93eSDaniel Fojt'simple'
2896008e37b6SJohn Marino     Always make simple backups.
2897008e37b6SJohn Marino
2898*6ea1f93eSDaniel Fojt   You can also tell 'patch' to prepend a prefix, such as a directory
2899*6ea1f93eSDaniel Fojtname, to produce backup file names.  The '--prefix=PREFIX' ('-B PREFIX')
2900*6ea1f93eSDaniel Fojtoption makes backup files by prepending PREFIX to them.  The
2901*6ea1f93eSDaniel Fojt'--basename-prefix=PREFIX' ('-Y PREFIX') prepends PREFIX to the last
2902*6ea1f93eSDaniel Fojtfile name component of backup file names instead; for example, '-Y ~'
2903*6ea1f93eSDaniel Fojtcauses the backup name for 'dir/file.c' to be 'dir/~file.c'.  If you use
2904*6ea1f93eSDaniel Fojteither of these prefix options, the suffix-based options are ignored.
2905008e37b6SJohn Marino
2906*6ea1f93eSDaniel Fojt   If you specify the output file with the '-o' option, that file is the
2907*6ea1f93eSDaniel Fojtone that is backed up, not the input file.
2908008e37b6SJohn Marino
2909008e37b6SJohn Marino   Options that affect the names of backup files do not affect whether
2910008e37b6SJohn Marinobackups are made.  For example, if you specify the
2911*6ea1f93eSDaniel Fojt'--no-backup-if-mismatch' option, none of the options described in this
2912008e37b6SJohn Marinosection have any affect, because no backups are made.
2913008e37b6SJohn Marino
2914008e37b6SJohn Marino   ---------- Footnotes ----------
2915008e37b6SJohn Marino
2916*6ea1f93eSDaniel Fojt   (1) A coding error in GNU 'patch' version 2.5.4 causes it to always
2917*6ea1f93eSDaniel Fojtuse '~', but this should be fixed in the next release.
2918008e37b6SJohn Marino
2919008e37b6SJohn Marino
2920*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Reject Names,  Next: patch Messages,  Prev: Backup Names,  Up: Merging with patch
2921008e37b6SJohn Marino
2922008e37b6SJohn Marino10.10 Reject File Names
2923008e37b6SJohn Marino=======================
2924008e37b6SJohn Marino
2925*6ea1f93eSDaniel FojtThe names for reject files (files containing patches that 'patch' could
2926*6ea1f93eSDaniel Fojtnot find a place to apply) are normally the name of the output file with
2927*6ea1f93eSDaniel Fojt'.rej' appended (or '#' if using '.rej' would make the backup file name
2928*6ea1f93eSDaniel Fojttoo long).
2929008e37b6SJohn Marino
2930*6ea1f93eSDaniel Fojt   Alternatively, you can tell 'patch' to place all of the rejected
2931*6ea1f93eSDaniel Fojtpatches in a single file.  The '-r REJECT-FILE' or
2932*6ea1f93eSDaniel Fojt'--reject-file=REJECT-FILE' option uses REJECT-FILE as the reject file
2933008e37b6SJohn Marinoname.
2934008e37b6SJohn Marino
2935008e37b6SJohn Marino
2936*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch Messages,  Next: patch and POSIX,  Prev: Reject Names,  Up: Merging with patch
2937008e37b6SJohn Marino
2938*6ea1f93eSDaniel Fojt10.11 Messages and Questions from 'patch'
2939008e37b6SJohn Marino=========================================
2940008e37b6SJohn Marino
2941*6ea1f93eSDaniel Fojt'patch' can produce a variety of messages, especially if it has trouble
2942008e37b6SJohn Marinodecoding its input.  In a few situations where it's not sure how to
2943*6ea1f93eSDaniel Fojtproceed, 'patch' normally prompts you for more information from the
2944008e37b6SJohn Marinokeyboard.  There are options to produce more or fewer messages, to have
2945*6ea1f93eSDaniel Fojtit not ask for keyboard input, and to affect the way that file names are
2946*6ea1f93eSDaniel Fojtquoted in messages.
2947008e37b6SJohn Marino
2948008e37b6SJohn Marino* Menu:
2949008e37b6SJohn Marino
2950*6ea1f93eSDaniel Fojt* More or Fewer Messages::    Controlling the verbosity of 'patch'.
2951008e37b6SJohn Marino* patch and Keyboard Input::  Inhibiting keyboard input.
2952008e37b6SJohn Marino* patch Quoting Style::       Quoting file names in diagnostics.
2953008e37b6SJohn Marino
2954*6ea1f93eSDaniel Fojt   'patch' exits with status 0 if all hunks are applied successfully, 1
2955008e37b6SJohn Marinoif some hunks cannot be applied, and 2 if there is more serious trouble.
2956008e37b6SJohn MarinoWhen applying a set of patches in a loop, you should check the exit
2957008e37b6SJohn Marinostatus, so you don't apply a later patch to a partially patched file.
2958008e37b6SJohn Marino
2959008e37b6SJohn Marino
2960*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: More or Fewer Messages,  Next: patch and Keyboard Input,  Up: patch Messages
2961008e37b6SJohn Marino
2962*6ea1f93eSDaniel Fojt10.11.1 Controlling the Verbosity of 'patch'
2963008e37b6SJohn Marino--------------------------------------------
2964008e37b6SJohn Marino
2965*6ea1f93eSDaniel FojtYou can cause 'patch' to produce more messages by using the '--verbose'
2966*6ea1f93eSDaniel Fojtoption.  For example, when you give this option, the message 'Hmm...'
2967*6ea1f93eSDaniel Fojtindicates that 'patch' is reading text in the patch file, attempting to
2968*6ea1f93eSDaniel Fojtdetermine whether there is a patch in that text, and if so, what kind of
2969*6ea1f93eSDaniel Fojtpatch it is.
2970008e37b6SJohn Marino
2971*6ea1f93eSDaniel Fojt   You can inhibit all terminal output from 'patch', unless an error
2972*6ea1f93eSDaniel Fojtoccurs, by using the '-s', '--quiet', or '--silent' option.
2973008e37b6SJohn Marino
2974008e37b6SJohn Marino
2975*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch and Keyboard Input,  Next: patch Quoting Style,  Prev: More or Fewer Messages,  Up: patch Messages
2976008e37b6SJohn Marino
2977008e37b6SJohn Marino10.11.2 Inhibiting Keyboard Input
2978008e37b6SJohn Marino---------------------------------
2979008e37b6SJohn Marino
2980*6ea1f93eSDaniel FojtThere are two ways you can prevent 'patch' from asking you any
2981*6ea1f93eSDaniel Fojtquestions.  The '--force' ('-f') option assumes that you know what you
2982*6ea1f93eSDaniel Fojtare doing.  It causes 'patch' to do the following:
2983008e37b6SJohn Marino
2984008e37b6SJohn Marino   * Skip patches that do not contain file names in their headers.
2985008e37b6SJohn Marino
2986008e37b6SJohn Marino   * Patch files even though they have the wrong version for the
2987*6ea1f93eSDaniel Fojt     'Prereq:' line in the patch;
2988008e37b6SJohn Marino
2989008e37b6SJohn Marino   * Assume that patches are not reversed even if they look like they
2990008e37b6SJohn Marino     are.
2991008e37b6SJohn Marino
2992*6ea1f93eSDaniel FojtThe '--batch' ('-t') option is similar to '-f', in that it suppresses
2993008e37b6SJohn Marinoquestions, but it makes somewhat different assumptions:
2994008e37b6SJohn Marino
2995008e37b6SJohn Marino   * Skip patches that do not contain file names in their headers (the
2996*6ea1f93eSDaniel Fojt     same as '-f').
2997008e37b6SJohn Marino
2998008e37b6SJohn Marino   * Skip patches for which the file has the wrong version for the
2999*6ea1f93eSDaniel Fojt     'Prereq:' line in the patch;
3000008e37b6SJohn Marino
3001008e37b6SJohn Marino   * Assume that patches are reversed if they look like they are.
3002008e37b6SJohn Marino
3003008e37b6SJohn Marino
3004*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch Quoting Style,  Prev: patch and Keyboard Input,  Up: patch Messages
3005008e37b6SJohn Marino
3006*6ea1f93eSDaniel Fojt10.11.3 'patch' Quoting Style
3007008e37b6SJohn Marino-----------------------------
3008008e37b6SJohn Marino
3009*6ea1f93eSDaniel FojtWhen 'patch' outputs a file name in a diagnostic message, it can format
3010008e37b6SJohn Marinothe name in any of several ways.  This can be useful to output file
3011008e37b6SJohn Marinonames unambiguously, even if they contain punctuation or special
3012*6ea1f93eSDaniel Fojtcharacters like newlines.  The '--quoting-style=WORD' option controls
3013008e37b6SJohn Marinohow names are output.  The WORD should be one of the following:
3014008e37b6SJohn Marino
3015*6ea1f93eSDaniel Fojt'literal'
3016008e37b6SJohn Marino     Output names as-is.
3017*6ea1f93eSDaniel Fojt'shell'
3018008e37b6SJohn Marino     Quote names for the shell if they contain shell metacharacters or
3019008e37b6SJohn Marino     would cause ambiguous output.
3020*6ea1f93eSDaniel Fojt'shell-always'
3021008e37b6SJohn Marino     Quote names for the shell, even if they would normally not require
3022008e37b6SJohn Marino     quoting.
3023*6ea1f93eSDaniel Fojt'c'
3024008e37b6SJohn Marino     Quote names as for a C language string.
3025*6ea1f93eSDaniel Fojt'escape'
3026*6ea1f93eSDaniel Fojt     Quote as with 'c' except omit the surrounding double-quote
3027008e37b6SJohn Marino     characters.
3028008e37b6SJohn Marino
3029*6ea1f93eSDaniel Fojt   You can specify the default value of the '--quoting-style' option
3030*6ea1f93eSDaniel Fojtwith the environment variable 'QUOTING_STYLE'.  If that environment
3031*6ea1f93eSDaniel Fojtvariable is not set, the default value is 'shell', but this default may
3032*6ea1f93eSDaniel Fojtchange in a future version of 'patch'.
3033008e37b6SJohn Marino
3034008e37b6SJohn Marino
3035*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch and POSIX,  Next: patch and Tradition,  Prev: patch Messages,  Up: Merging with patch
3036008e37b6SJohn Marino
3037*6ea1f93eSDaniel Fojt10.12 'patch' and the POSIX Standard
3038008e37b6SJohn Marino====================================
3039008e37b6SJohn Marino
3040*6ea1f93eSDaniel FojtIf you specify the '--posix' option, or set the 'POSIXLY_CORRECT'
3041*6ea1f93eSDaniel Fojtenvironment variable, 'patch' conforms more strictly to the POSIX
3042008e37b6SJohn Marinostandard, as follows:
3043008e37b6SJohn Marino
3044008e37b6SJohn Marino   * Take the first existing file from the list (old, new, index) when
3045008e37b6SJohn Marino     intuiting file names from diff headers.  *Note Multiple Patches::.
3046008e37b6SJohn Marino
3047*6ea1f93eSDaniel Fojt   * Do not remove files that are removed by a diff.  *Note Creating and
3048*6ea1f93eSDaniel Fojt     Removing::.
3049008e37b6SJohn Marino
3050*6ea1f93eSDaniel Fojt   * Do not ask whether to get files from RCS, ClearCase, or SCCS. *Note
3051*6ea1f93eSDaniel Fojt     Revision Control::.
3052008e37b6SJohn Marino
3053008e37b6SJohn Marino   * Require that all options precede the files in the command line.
3054008e37b6SJohn Marino
3055008e37b6SJohn Marino   * Do not backup files, even when there is a mismatch.  *Note
3056008e37b6SJohn Marino     Backups::.
3057008e37b6SJohn Marino
3058008e37b6SJohn Marino
3059*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch and Tradition,  Prev: patch and POSIX,  Up: Merging with patch
3060008e37b6SJohn Marino
3061*6ea1f93eSDaniel Fojt10.13 GNU 'patch' and Traditional 'patch'
3062008e37b6SJohn Marino=========================================
3063008e37b6SJohn Marino
3064*6ea1f93eSDaniel FojtThe current version of GNU 'patch' normally follows the POSIX standard.
3065008e37b6SJohn Marino*Note patch and POSIX::, for the few exceptions to this general rule.
3066008e37b6SJohn Marino
3067*6ea1f93eSDaniel Fojt   Unfortunately, POSIX redefined the behavior of 'patch' in several
3068*6ea1f93eSDaniel Fojtimportant ways.  You should be aware of the following differences if you
3069*6ea1f93eSDaniel Fojtmust interoperate with traditional 'patch', or with GNU 'patch' version
3070*6ea1f93eSDaniel Fojt2.1 and earlier.
3071008e37b6SJohn Marino
3072*6ea1f93eSDaniel Fojt   * In traditional 'patch', the '-p' option's operand was optional, and
3073*6ea1f93eSDaniel Fojt     a bare '-p' was equivalent to '-p0'.  The '-p' option now requires
3074*6ea1f93eSDaniel Fojt     an operand, and '-p 0' is now equivalent to '-p0'.  For maximum
3075*6ea1f93eSDaniel Fojt     compatibility, use options like '-p0' and '-p1'.
3076008e37b6SJohn Marino
3077*6ea1f93eSDaniel Fojt     Also, traditional 'patch' simply counted slashes when stripping
3078*6ea1f93eSDaniel Fojt     path prefixes; 'patch' now counts pathname components.  That is, a
3079008e37b6SJohn Marino     sequence of one or more adjacent slashes now counts as a single
3080008e37b6SJohn Marino     slash.  For maximum portability, avoid sending patches containing
3081*6ea1f93eSDaniel Fojt     '//' in file names.
3082008e37b6SJohn Marino
3083*6ea1f93eSDaniel Fojt   * In traditional 'patch', backups were enabled by default.  This
3084*6ea1f93eSDaniel Fojt     behavior is now enabled with the '--backup' ('-b') option.
3085008e37b6SJohn Marino
3086*6ea1f93eSDaniel Fojt     Conversely, in POSIX 'patch', backups are never made, even when
3087*6ea1f93eSDaniel Fojt     there is a mismatch.  In GNU 'patch', this behavior is enabled with
3088*6ea1f93eSDaniel Fojt     the '--no-backup-if-mismatch' option, or by conforming to POSIX.
3089008e37b6SJohn Marino
3090*6ea1f93eSDaniel Fojt     The '-b SUFFIX' option of traditional 'patch' is equivalent to the
3091*6ea1f93eSDaniel Fojt     '-b -z SUFFIX' options of GNU 'patch'.
3092008e37b6SJohn Marino
3093*6ea1f93eSDaniel Fojt   * Traditional 'patch' used a complicated (and incompletely
3094008e37b6SJohn Marino     documented) method to intuit the name of the file to be patched
3095008e37b6SJohn Marino     from the patch header.  This method did not conform to POSIX, and
3096*6ea1f93eSDaniel Fojt     had a few gotchas.  Now 'patch' uses a different, equally
3097008e37b6SJohn Marino     complicated (but better documented) method that is optionally
3098008e37b6SJohn Marino     POSIX-conforming; we hope it has fewer gotchas.  The two methods
3099008e37b6SJohn Marino     are compatible if the file names in the context diff header and the
3100*6ea1f93eSDaniel Fojt     'Index:' line are all identical after prefix-stripping.  Your patch
3101*6ea1f93eSDaniel Fojt     is normally compatible if each header's file names all contain the
3102*6ea1f93eSDaniel Fojt     same number of slashes.
3103008e37b6SJohn Marino
3104*6ea1f93eSDaniel Fojt   * When traditional 'patch' asked the user a question, it sent the
3105008e37b6SJohn Marino     question to standard error and looked for an answer from the first
3106008e37b6SJohn Marino     file in the following list that was a terminal: standard error,
3107*6ea1f93eSDaniel Fojt     standard output, '/dev/tty', and standard input.  Now 'patch' sends
3108*6ea1f93eSDaniel Fojt     questions to standard output and gets answers from '/dev/tty'.
3109*6ea1f93eSDaniel Fojt     Defaults for some answers have been changed so that 'patch' never
3110*6ea1f93eSDaniel Fojt     goes into an infinite loop when using default answers.
3111008e37b6SJohn Marino
3112*6ea1f93eSDaniel Fojt   * Traditional 'patch' exited with a status value that counted the
3113008e37b6SJohn Marino     number of bad hunks, or with status 1 if there was real trouble.
3114*6ea1f93eSDaniel Fojt     Now 'patch' exits with status 1 if some hunks failed, or with 2 if
3115008e37b6SJohn Marino     there was real trouble.
3116008e37b6SJohn Marino
3117008e37b6SJohn Marino   * Limit yourself to the following options when sending instructions
3118*6ea1f93eSDaniel Fojt     meant to be executed by anyone running GNU 'patch', traditional
3119*6ea1f93eSDaniel Fojt     'patch', or a 'patch' that conforms to POSIX. Spaces are
3120008e37b6SJohn Marino     significant in the following list, and operands are required.
3121008e37b6SJohn Marino
3122*6ea1f93eSDaniel Fojt          -c
3123*6ea1f93eSDaniel Fojt          -d DIR
3124*6ea1f93eSDaniel Fojt          -D DEFINE
3125*6ea1f93eSDaniel Fojt          -e
3126*6ea1f93eSDaniel Fojt          -l
3127*6ea1f93eSDaniel Fojt          -n
3128*6ea1f93eSDaniel Fojt          -N
3129*6ea1f93eSDaniel Fojt          -o OUTFILE
3130*6ea1f93eSDaniel Fojt          -pNUM
3131*6ea1f93eSDaniel Fojt          -R
3132*6ea1f93eSDaniel Fojt          -r REJECTFILE
3133008e37b6SJohn Marino
3134008e37b6SJohn Marino
3135*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Making Patches,  Next: Invoking cmp,  Prev: Merging with patch,  Up: Top
3136008e37b6SJohn Marino
3137008e37b6SJohn Marino11 Tips for Making and Using Patches
3138008e37b6SJohn Marino************************************
3139008e37b6SJohn Marino
3140008e37b6SJohn MarinoUse some common sense when making and using patches.  For example, when
3141*6ea1f93eSDaniel Fojtsending bug fixes to a program's maintainer, send several small patches,
3142*6ea1f93eSDaniel Fojtone per independent subject, instead of one large, harder-to-digest
3143*6ea1f93eSDaniel Fojtpatch that covers all the subjects.
3144008e37b6SJohn Marino
3145008e37b6SJohn Marino   Here are some other things you should keep in mind if you are going
3146008e37b6SJohn Marinoto distribute patches for updating a software package.
3147008e37b6SJohn Marino
3148008e37b6SJohn Marino* Menu:
3149008e37b6SJohn Marino
3150008e37b6SJohn Marino* Tips for Patch Producers::    Advice for making patches.
3151008e37b6SJohn Marino* Tips for Patch Consumers::    Advice for using patches.
3152*6ea1f93eSDaniel Fojt* Avoiding Common Mistakes::    Avoiding common mistakes when using 'patch'.
3153008e37b6SJohn Marino* Generating Smaller Patches::  How to generate smaller patches.
3154008e37b6SJohn Marino
3155008e37b6SJohn Marino
3156*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Tips for Patch Producers,  Next: Tips for Patch Consumers,  Up: Making Patches
3157008e37b6SJohn Marino
3158008e37b6SJohn Marino11.1 Tips for Patch Producers
3159008e37b6SJohn Marino=============================
3160008e37b6SJohn Marino
3161008e37b6SJohn MarinoTo create a patch that changes an older version of a package into a
3162008e37b6SJohn Marinonewer version, first make a copy of the older and newer versions in
3163*6ea1f93eSDaniel Fojtadjacent subdirectories.  It is common to do that by unpacking 'tar'
3164008e37b6SJohn Marinoarchives of the two versions.
3165008e37b6SJohn Marino
3166*6ea1f93eSDaniel Fojt   To generate the patch, use the command 'diff -Naur OLD NEW' where OLD
3167*6ea1f93eSDaniel Fojtand NEW identify the old and new directories.  The names OLD and NEW
3168*6ea1f93eSDaniel Fojtshould not contain any slashes.  The '-N' option lets the patch create
3169*6ea1f93eSDaniel Fojtand remove files; '-a' lets the patch update non-text files; '-u'
3170*6ea1f93eSDaniel Fojtgenerates useful timestamps and enough context; and '-r' lets the patch
3171*6ea1f93eSDaniel Fojtupdate subdirectories.  Here is an example command, using Bourne shell
3172*6ea1f93eSDaniel Fojtsyntax:
3173008e37b6SJohn Marino
3174008e37b6SJohn Marino     diff -Naur gcc-3.0.3 gcc-3.0.4
3175008e37b6SJohn Marino
3176008e37b6SJohn Marino   Tell your recipients how to apply the patches.  This should include
3177*6ea1f93eSDaniel Fojtwhich working directory to use, and which 'patch' options to use; the
3178*6ea1f93eSDaniel Fojtoption '-p1' is recommended.  Test your procedure by pretending to be a
3179008e37b6SJohn Marinorecipient and applying your patches to a copy of the original files.
3180008e37b6SJohn Marino
3181008e37b6SJohn Marino   *Note Avoiding Common Mistakes::, for how to avoid common mistakes
3182008e37b6SJohn Marinowhen generating a patch.
3183008e37b6SJohn Marino
3184008e37b6SJohn Marino
3185*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Tips for Patch Consumers,  Next: Avoiding Common Mistakes,  Prev: Tips for Patch Producers,  Up: Making Patches
3186008e37b6SJohn Marino
3187008e37b6SJohn Marino11.2 Tips for Patch Consumers
3188008e37b6SJohn Marino=============================
3189008e37b6SJohn Marino
3190*6ea1f93eSDaniel FojtA patch producer should tell recipients how to apply the patches, so the
3191*6ea1f93eSDaniel Fojtfirst rule of thumb for a patch consumer is to follow the instructions
3192*6ea1f93eSDaniel Fojtsupplied with the patch.
3193008e37b6SJohn Marino
3194*6ea1f93eSDaniel Fojt   GNU 'diff' can analyze files with arbitrarily long lines and files
3195*6ea1f93eSDaniel Fojtthat end in incomplete lines.  However, older versions of 'patch' cannot
3196*6ea1f93eSDaniel Fojtpatch such files.  If you are having trouble applying such patches, try
3197*6ea1f93eSDaniel Fojtupgrading to a recent version of GNU 'patch'.
3198008e37b6SJohn Marino
3199008e37b6SJohn Marino
3200*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Avoiding Common Mistakes,  Next: Generating Smaller Patches,  Prev: Tips for Patch Consumers,  Up: Making Patches
3201008e37b6SJohn Marino
3202008e37b6SJohn Marino11.3 Avoiding Common Mistakes
3203008e37b6SJohn Marino=============================
3204008e37b6SJohn Marino
3205*6ea1f93eSDaniel FojtWhen producing a patch for multiple files, apply 'diff' to directories
3206008e37b6SJohn Marinowhose names do not have slashes.  This reduces confusion when the patch
3207*6ea1f93eSDaniel Fojtconsumer specifies the '-pNUMBER' option, since this option can have
3208008e37b6SJohn Marinosurprising results when the old and new file names have different
3209*6ea1f93eSDaniel Fojtnumbers of slashes.  For example, do not send a patch with a header that
3210*6ea1f93eSDaniel Fojtlooks like this:
3211008e37b6SJohn Marino
3212008e37b6SJohn Marino     diff -Naur v2.0.29/prog/README prog/README
3213008e37b6SJohn Marino     --- v2.0.29/prog/README	2002-03-10 23:30:39.942229878 -0800
3214008e37b6SJohn Marino     +++ prog/README	2002-03-17 20:49:32.442260588 -0800
3215008e37b6SJohn Marino
3216008e37b6SJohn Marinobecause the two file names have different numbers of slashes, and
3217*6ea1f93eSDaniel Fojtdifferent versions of 'patch' interpret the file names differently.  To
3218008e37b6SJohn Marinoavoid confusion, send output that looks like this instead:
3219008e37b6SJohn Marino
3220008e37b6SJohn Marino     diff -Naur v2.0.29/prog/README v2.0.30/prog/README
3221008e37b6SJohn Marino     --- v2.0.29/prog/README	2002-03-10 23:30:39.942229878 -0800
3222008e37b6SJohn Marino     +++ v2.0.30/prog/README	2002-03-17 20:49:32.442260588 -0800
3223008e37b6SJohn Marino
3224008e37b6SJohn Marino   Make sure you have specified the file names correctly, either in a
3225*6ea1f93eSDaniel Fojtcontext diff header or with an 'Index:' line.  Take care to not send out
3226008e37b6SJohn Marinoreversed patches, since these make people wonder whether they have
3227008e37b6SJohn Marinoalready applied the patch.
3228008e37b6SJohn Marino
3229008e37b6SJohn Marino   Avoid sending patches that compare backup file names like
3230*6ea1f93eSDaniel Fojt'README.orig' or 'README~', since this might confuse 'patch' into
3231008e37b6SJohn Marinopatching a backup file instead of the real file.  Instead, send patches
3232008e37b6SJohn Marinothat compare the same base file names in different directories, e.g.
3233*6ea1f93eSDaniel Fojt'old/README' and 'new/README'.
3234008e37b6SJohn Marino
3235008e37b6SJohn Marino   To save people from partially applying a patch before other patches
3236008e37b6SJohn Marinothat should have gone before it, you can make the first patch in the
3237*6ea1f93eSDaniel Fojtpatch file update a file with a name like 'patchlevel.h' or 'version.c',
3238*6ea1f93eSDaniel Fojtwhich contains a patch level or version number.  If the input file
3239*6ea1f93eSDaniel Fojtcontains the wrong version number, 'patch' will complain immediately.
3240008e37b6SJohn Marino
3241*6ea1f93eSDaniel Fojt   An even clearer way to prevent this problem is to put a 'Prereq:'
3242008e37b6SJohn Marinoline before the patch.  If the leading text in the patch file contains a
3243*6ea1f93eSDaniel Fojtline that starts with 'Prereq:', 'patch' takes the next word from that
3244008e37b6SJohn Marinoline (normally a version number) and checks whether the next input file
3245008e37b6SJohn Marinocontains that word, preceded and followed by either white space or a
3246*6ea1f93eSDaniel Fojtnewline.  If not, 'patch' prompts you for confirmation before
3247008e37b6SJohn Marinoproceeding.  This makes it difficult to accidentally apply patches in
3248008e37b6SJohn Marinothe wrong order.
3249008e37b6SJohn Marino
3250008e37b6SJohn Marino
3251*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Generating Smaller Patches,  Prev: Avoiding Common Mistakes,  Up: Making Patches
3252008e37b6SJohn Marino
3253008e37b6SJohn Marino11.4 Generating Smaller Patches
3254008e37b6SJohn Marino===============================
3255008e37b6SJohn Marino
3256*6ea1f93eSDaniel FojtThe simplest way to generate a patch is to use 'diff -Naur' (*note Tips
3257008e37b6SJohn Marinofor Patch Producers::), but you might be able to reduce the size of the
3258008e37b6SJohn Marinopatch by renaming or removing some files before making the patch.  If
3259008e37b6SJohn Marinothe older version of the package contains any files that the newer
3260008e37b6SJohn Marinoversion does not, or if any files have been renamed between the two
3261*6ea1f93eSDaniel Fojtversions, make a list of 'rm' and 'mv' commands for the user to execute
3262008e37b6SJohn Marinoin the old version directory before applying the patch.  Then run those
3263008e37b6SJohn Marinocommands yourself in the scratch directory.
3264008e37b6SJohn Marino
3265008e37b6SJohn Marino   If there are any files that you don't need to include in the patch
3266*6ea1f93eSDaniel Fojtbecause they can easily be rebuilt from other files (for example, 'TAGS'
3267*6ea1f93eSDaniel Fojtand output from 'yacc' and 'makeinfo'), exclude them from the patch by
3268*6ea1f93eSDaniel Fojtgiving 'diff' the '-x PATTERN' option (*note Comparing Directories::).
3269*6ea1f93eSDaniel FojtIf you want your patch to modify a derived file because your recipients
3270*6ea1f93eSDaniel Fojtlack tools to build it, make sure that the patch for the derived file
3271*6ea1f93eSDaniel Fojtfollows any patches for files that it depends on, so that the
3272*6ea1f93eSDaniel Fojtrecipients' timestamps will not confuse 'make'.
3273008e37b6SJohn Marino
3274*6ea1f93eSDaniel Fojt   Now you can create the patch using 'diff -Naur'.  Make sure to
3275008e37b6SJohn Marinospecify the scratch directory first and the newer directory second.
3276008e37b6SJohn Marino
3277*6ea1f93eSDaniel Fojt   Add to the top of the patch a note telling the user any 'rm' and 'mv'
3278*6ea1f93eSDaniel Fojtcommands to run before applying the patch.  Then you can remove the
3279*6ea1f93eSDaniel Fojtscratch directory.
3280008e37b6SJohn Marino
3281008e37b6SJohn Marino   You can also shrink the patch size by using fewer lines of context,
3282*6ea1f93eSDaniel Fojtbut bear in mind that 'patch' typically needs at least two lines for
3283008e37b6SJohn Marinoproper operation when patches do not exactly match the input files.
3284008e37b6SJohn Marino
3285008e37b6SJohn Marino
3286*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Invoking cmp,  Next: Invoking diff,  Prev: Making Patches,  Up: Top
3287008e37b6SJohn Marino
3288*6ea1f93eSDaniel Fojt12 Invoking 'cmp'
3289008e37b6SJohn Marino*****************
3290008e37b6SJohn Marino
3291*6ea1f93eSDaniel FojtThe 'cmp' command compares two files, and if they differ, tells the
3292*6ea1f93eSDaniel Fojtfirst byte and line number where they differ or reports that one file is
3293*6ea1f93eSDaniel Fojta prefix of the other.  Bytes and lines are numbered starting with 1.
3294*6ea1f93eSDaniel FojtThe arguments of 'cmp' are as follows:
3295008e37b6SJohn Marino
3296008e37b6SJohn Marino     cmp OPTIONS... FROM-FILE [TO-FILE [FROM-SKIP [TO-SKIP]]]
3297008e37b6SJohn Marino
3298*6ea1f93eSDaniel Fojt   The file name '-' is always the standard input.  'cmp' also uses the
3299008e37b6SJohn Marinostandard input if one file name is omitted.  The FROM-SKIP and TO-SKIP
3300008e37b6SJohn Marinooperands specify how many bytes to ignore at the start of each file;
3301*6ea1f93eSDaniel Fojtthey are equivalent to the '--ignore-initial=FROM-SKIP:TO-SKIP' option.
3302008e37b6SJohn Marino
3303*6ea1f93eSDaniel Fojt   By default, 'cmp' outputs nothing if the two files have the same
3304*6ea1f93eSDaniel Fojtcontents.  If the two files have bytes that differ, 'cmp' reports the
3305*6ea1f93eSDaniel Fojtlocation of the first difference to standard output:
3306008e37b6SJohn Marino
3307008e37b6SJohn Marino     FROM-FILE TO-FILE differ: char BYTE-NUMBER, line LINE-NUMBER
3308008e37b6SJohn Marino
3309*6ea1f93eSDaniel FojtIf one file is a prefix of the other, 'cmp' reports the shorter file's
3310*6ea1f93eSDaniel Fojtname to standard error, followed by a blank and extra information about
3311*6ea1f93eSDaniel Fojtthe shorter file:
3312*6ea1f93eSDaniel Fojt
3313*6ea1f93eSDaniel Fojt     cmp: EOF on SHORTER-FILE EXTRA-INFO
3314*6ea1f93eSDaniel Fojt
3315*6ea1f93eSDaniel Fojt   The message formats can differ outside the POSIX locale.  POSIX
3316*6ea1f93eSDaniel Fojtallows but does not require the EOF diagnostic's file name to be
3317*6ea1f93eSDaniel Fojtfollowed by a blank and additional information.
3318008e37b6SJohn Marino
3319008e37b6SJohn Marino   An exit status of 0 means no differences were found, 1 means some
3320008e37b6SJohn Marinodifferences were found, and 2 means trouble.
3321008e37b6SJohn Marino
3322008e37b6SJohn Marino* Menu:
3323008e37b6SJohn Marino
3324*6ea1f93eSDaniel Fojt* cmp Options:: Summary of options to 'cmp'.
3325008e37b6SJohn Marino
3326008e37b6SJohn Marino
3327*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: cmp Options,  Up: Invoking cmp
3328008e37b6SJohn Marino
3329*6ea1f93eSDaniel Fojt12.1 Options to 'cmp'
3330008e37b6SJohn Marino=====================
3331008e37b6SJohn Marino
3332*6ea1f93eSDaniel FojtBelow is a summary of all of the options that GNU 'cmp' accepts.  Most
3333008e37b6SJohn Marinooptions have two equivalent names, one of which is a single letter
3334*6ea1f93eSDaniel Fojtpreceded by '-', and the other of which is a long name preceded by '--'.
3335*6ea1f93eSDaniel FojtMultiple single letter options (unless they take an argument) can be
3336*6ea1f93eSDaniel Fojtcombined into a single command line word: '-bl' is equivalent to '-b
3337*6ea1f93eSDaniel Fojt-l'.
3338008e37b6SJohn Marino
3339*6ea1f93eSDaniel Fojt'-b'
3340*6ea1f93eSDaniel Fojt'--print-bytes'
3341*6ea1f93eSDaniel Fojt     Print the differing bytes.  Display control bytes as a '^' followed
3342*6ea1f93eSDaniel Fojt     by a letter of the alphabet and precede bytes that have the high
3343*6ea1f93eSDaniel Fojt     bit set with 'M-' (which stands for "meta").
3344008e37b6SJohn Marino
3345*6ea1f93eSDaniel Fojt'--help'
3346008e37b6SJohn Marino     Output a summary of usage and then exit.
3347008e37b6SJohn Marino
3348*6ea1f93eSDaniel Fojt'-i SKIP'
3349*6ea1f93eSDaniel Fojt'--ignore-initial=SKIP'
3350008e37b6SJohn Marino     Ignore any differences in the first SKIP bytes of the input files.
3351008e37b6SJohn Marino     Treat files with fewer than SKIP bytes as if they are empty.  If
3352*6ea1f93eSDaniel Fojt     SKIP is of the form 'FROM-SKIP:TO-SKIP', skip the first FROM-SKIP
3353008e37b6SJohn Marino     bytes of the first input file and the first TO-SKIP bytes of the
3354008e37b6SJohn Marino     second.
3355008e37b6SJohn Marino
3356*6ea1f93eSDaniel Fojt'-l'
3357*6ea1f93eSDaniel Fojt'--verbose'
3358008e37b6SJohn Marino     Output the (decimal) byte numbers and (octal) values of all
33594536c563SJohn Marino     differing bytes, instead of the default standard output.  Each
33604536c563SJohn Marino     output line contains a differing byte's number relative to the
33614536c563SJohn Marino     start of the input, followed by the differing byte values.  Byte
33624536c563SJohn Marino     numbers start at 1.  Also, output the EOF message if one file is
33634536c563SJohn Marino     shorter than the other.
3364008e37b6SJohn Marino
3365*6ea1f93eSDaniel Fojt'-n COUNT'
3366*6ea1f93eSDaniel Fojt'--bytes=COUNT'
3367008e37b6SJohn Marino     Compare at most COUNT input bytes.
3368008e37b6SJohn Marino
3369*6ea1f93eSDaniel Fojt'-s'
3370*6ea1f93eSDaniel Fojt'--quiet'
3371*6ea1f93eSDaniel Fojt'--silent'
3372008e37b6SJohn Marino     Do not print anything; only return an exit status indicating
3373008e37b6SJohn Marino     whether the files differ.
3374008e37b6SJohn Marino
3375*6ea1f93eSDaniel Fojt'-v'
3376*6ea1f93eSDaniel Fojt'--version'
3377008e37b6SJohn Marino     Output version information and then exit.
3378008e37b6SJohn Marino
3379008e37b6SJohn Marino   In the above table, operands that are byte counts are normally
3380*6ea1f93eSDaniel Fojtdecimal, but may be preceded by '0' for octal and '0x' for hexadecimal.
3381008e37b6SJohn Marino
3382008e37b6SJohn Marino   A byte count can be followed by a suffix to specify a multiple of
3383008e37b6SJohn Marinothat count; in this case an omitted integer is understood to be 1.  A
3384*6ea1f93eSDaniel Fojtbare size letter, or one followed by 'iB', specifies a multiple using
3385*6ea1f93eSDaniel Fojtpowers of 1024.  A size letter followed by 'B' specifies powers of 1000
3386*6ea1f93eSDaniel Fojtinstead.  For example, '-n 4M' and '-n 4MiB' are equivalent to '-n
3387*6ea1f93eSDaniel Fojt4194304', whereas '-n 4MB' is equivalent to '-n 4000000'.  This notation
3388*6ea1f93eSDaniel Fojtis upward compatible with the SI prefixes
3389008e37b6SJohn Marino(http://www.bipm.fr/enus/3_SI/si-prefixes.html) for decimal multiples
3390008e37b6SJohn Marinoand with the IEC 60027-2 prefixes for binary multiples
3391008e37b6SJohn Marino(http://physics.nist.gov/cuu/Units/binary.html).
3392008e37b6SJohn Marino
3393*6ea1f93eSDaniel Fojt   The following suffixes are defined.  Large sizes like '1Y' may be
3394008e37b6SJohn Marinorejected by your computer due to limitations of its arithmetic.
3395008e37b6SJohn Marino
3396*6ea1f93eSDaniel Fojt'kB'
3397008e37b6SJohn Marino     kilobyte: 10^3 = 1000.
3398*6ea1f93eSDaniel Fojt'k'
3399*6ea1f93eSDaniel Fojt'K'
3400*6ea1f93eSDaniel Fojt'KiB'
3401*6ea1f93eSDaniel Fojt     kibibyte: 2^10 = 1024.  'K' is special: the SI prefix is 'k' and
3402*6ea1f93eSDaniel Fojt     the IEC 60027-2 prefix is 'Ki', but tradition and POSIX use 'k' to
3403*6ea1f93eSDaniel Fojt     mean 'KiB'.
3404*6ea1f93eSDaniel Fojt'MB'
3405008e37b6SJohn Marino     megabyte: 10^6 = 1,000,000.
3406*6ea1f93eSDaniel Fojt'M'
3407*6ea1f93eSDaniel Fojt'MiB'
3408008e37b6SJohn Marino     mebibyte: 2^20 = 1,048,576.
3409*6ea1f93eSDaniel Fojt'GB'
3410008e37b6SJohn Marino     gigabyte: 10^9 = 1,000,000,000.
3411*6ea1f93eSDaniel Fojt'G'
3412*6ea1f93eSDaniel Fojt'GiB'
3413008e37b6SJohn Marino     gibibyte: 2^30 = 1,073,741,824.
3414*6ea1f93eSDaniel Fojt'TB'
3415008e37b6SJohn Marino     terabyte: 10^12 = 1,000,000,000,000.
3416*6ea1f93eSDaniel Fojt'T'
3417*6ea1f93eSDaniel Fojt'TiB'
3418008e37b6SJohn Marino     tebibyte: 2^40 = 1,099,511,627,776.
3419*6ea1f93eSDaniel Fojt'PB'
3420008e37b6SJohn Marino     petabyte: 10^15 = 1,000,000,000,000,000.
3421*6ea1f93eSDaniel Fojt'P'
3422*6ea1f93eSDaniel Fojt'PiB'
3423008e37b6SJohn Marino     pebibyte: 2^50 = 1,125,899,906,842,624.
3424*6ea1f93eSDaniel Fojt'EB'
3425008e37b6SJohn Marino     exabyte: 10^18 = 1,000,000,000,000,000,000.
3426*6ea1f93eSDaniel Fojt'E'
3427*6ea1f93eSDaniel Fojt'EiB'
3428008e37b6SJohn Marino     exbibyte: 2^60 = 1,152,921,504,606,846,976.
3429*6ea1f93eSDaniel Fojt'ZB'
3430008e37b6SJohn Marino     zettabyte: 10^21 = 1,000,000,000,000,000,000,000
3431*6ea1f93eSDaniel Fojt'Z'
3432*6ea1f93eSDaniel Fojt'ZiB'
3433*6ea1f93eSDaniel Fojt     2^70 = 1,180,591,620,717,411,303,424.  ('Zi' is a GNU extension to
3434008e37b6SJohn Marino     IEC 60027-2.)
3435*6ea1f93eSDaniel Fojt'YB'
3436008e37b6SJohn Marino     yottabyte: 10^24 = 1,000,000,000,000,000,000,000,000.
3437*6ea1f93eSDaniel Fojt'Y'
3438*6ea1f93eSDaniel Fojt'YiB'
3439*6ea1f93eSDaniel Fojt     2^80 = 1,208,925,819,614,629,174,706,176.  ('Yi' is a GNU extension
3440*6ea1f93eSDaniel Fojt     to IEC 60027-2.)
3441008e37b6SJohn Marino
3442008e37b6SJohn Marino
3443*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Invoking diff,  Next: Invoking diff3,  Prev: Invoking cmp,  Up: Top
3444008e37b6SJohn Marino
3445*6ea1f93eSDaniel Fojt13 Invoking 'diff'
3446008e37b6SJohn Marino******************
3447008e37b6SJohn Marino
3448*6ea1f93eSDaniel FojtThe format for running the 'diff' command is:
3449008e37b6SJohn Marino
3450008e37b6SJohn Marino     diff OPTIONS... FILES...
3451008e37b6SJohn Marino
3452*6ea1f93eSDaniel Fojt   In the simplest case, two file names FROM-FILE and TO-FILE are given,
3453*6ea1f93eSDaniel Fojtand 'diff' compares the contents of FROM-FILE and TO-FILE.  A file name
3454*6ea1f93eSDaniel Fojtof '-' stands for the standard input.
3455008e37b6SJohn Marino
3456*6ea1f93eSDaniel Fojt   If one file is a directory and the other is not, 'diff' compares the
3457008e37b6SJohn Marinofile in the directory whose name is that of the non-directory.  The
3458*6ea1f93eSDaniel Fojtnon-directory file must not be '-'.
3459008e37b6SJohn Marino
3460*6ea1f93eSDaniel Fojt   If two file names are given and both are directories, 'diff' compares
3461*6ea1f93eSDaniel Fojtcorresponding files in both directories, in alphabetical order; this
3462*6ea1f93eSDaniel Fojtcomparison is not recursive unless the '--recursive' ('-r') option is
3463*6ea1f93eSDaniel Fojtgiven.  'diff' never compares the actual contents of a directory as if
3464*6ea1f93eSDaniel Fojtit were a file.  The file that is fully specified may not be standard
3465*6ea1f93eSDaniel Fojtinput, because standard input is nameless and the notion of "file with
3466*6ea1f93eSDaniel Fojtthe same name" does not apply.
3467008e37b6SJohn Marino
3468*6ea1f93eSDaniel Fojt   If the '--from-file=FILE' option is given, the number of file names
3469008e37b6SJohn Marinois arbitrary, and FILE is compared to each named file.  Similarly, if
3470*6ea1f93eSDaniel Fojtthe '--to-file=FILE' option is given, each named file is compared to
3471008e37b6SJohn MarinoFILE.
3472008e37b6SJohn Marino
3473*6ea1f93eSDaniel Fojt   'diff' options begin with '-', so normally file names may not begin
3474*6ea1f93eSDaniel Fojtwith '-'.  However, '--' as an argument by itself treats the remaining
3475*6ea1f93eSDaniel Fojtarguments as file names even if they begin with '-'.
3476008e37b6SJohn Marino
3477008e37b6SJohn Marino   An exit status of 0 means no differences were found, 1 means some
3478*6ea1f93eSDaniel Fojtdifferences were found, and 2 means trouble.
3479008e37b6SJohn Marino
3480008e37b6SJohn Marino* Menu:
3481008e37b6SJohn Marino
3482*6ea1f93eSDaniel Fojt* diff Options:: Summary of options to 'diff'.
3483008e37b6SJohn Marino
3484008e37b6SJohn Marino
3485*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: diff Options,  Up: Invoking diff
3486008e37b6SJohn Marino
3487*6ea1f93eSDaniel Fojt13.1 Options to 'diff'
3488008e37b6SJohn Marino======================
3489008e37b6SJohn Marino
3490*6ea1f93eSDaniel FojtBelow is a summary of all of the options that GNU 'diff' accepts.  Most
3491008e37b6SJohn Marinooptions have two equivalent names, one of which is a single letter
3492*6ea1f93eSDaniel Fojtpreceded by '-', and the other of which is a long name preceded by '--'.
3493*6ea1f93eSDaniel FojtMultiple single letter options (unless they take an argument) can be
3494*6ea1f93eSDaniel Fojtcombined into a single command line word: '-ac' is equivalent to '-a
3495*6ea1f93eSDaniel Fojt-c'.  Long named options can be abbreviated to any unique prefix of
3496008e37b6SJohn Marinotheir name.  Brackets ([ and ]) indicate that an option takes an
3497008e37b6SJohn Marinooptional argument.
3498008e37b6SJohn Marino
3499*6ea1f93eSDaniel Fojt'-a'
3500*6ea1f93eSDaniel Fojt'--text'
3501008e37b6SJohn Marino     Treat all files as text and compare them line-by-line, even if they
3502008e37b6SJohn Marino     do not seem to be text.  *Note Binary::.
3503008e37b6SJohn Marino
3504*6ea1f93eSDaniel Fojt'-b'
3505*6ea1f93eSDaniel Fojt'--ignore-space-change'
3506008e37b6SJohn Marino     Ignore changes in amount of white space.  *Note White Space::.
3507008e37b6SJohn Marino
3508*6ea1f93eSDaniel Fojt'-B'
3509*6ea1f93eSDaniel Fojt'--ignore-blank-lines'
3510*6ea1f93eSDaniel Fojt     Ignore changes that just insert or delete blank lines.  *Note Blank
3511*6ea1f93eSDaniel Fojt     Lines::.
3512008e37b6SJohn Marino
3513*6ea1f93eSDaniel Fojt'--binary'
3514008e37b6SJohn Marino     Read and write data in binary mode.  *Note Binary::.
3515008e37b6SJohn Marino
3516*6ea1f93eSDaniel Fojt'-c'
3517008e37b6SJohn Marino     Use the context output format, showing three lines of context.
3518008e37b6SJohn Marino     *Note Context Format::.
3519008e37b6SJohn Marino
3520*6ea1f93eSDaniel Fojt'--color [=WHEN]'
3521*6ea1f93eSDaniel Fojt     Specify whether to use color for distinguishing different contexts,
3522*6ea1f93eSDaniel Fojt     like header, added or removed lines.  WHEN may be omitted, or one
3523*6ea1f93eSDaniel Fojt     of:
3524*6ea1f93eSDaniel Fojt        * none Do not use color at all.  This is the default when no
3525*6ea1f93eSDaniel Fojt          -color option is specified.
3526*6ea1f93eSDaniel Fojt        * auto Use color only if standard output is a terminal.
3527*6ea1f93eSDaniel Fojt        * always Always use color.
3528*6ea1f93eSDaniel Fojt     Specifying '--color' and no WHEN is equivalent to '--color=auto'.
3529*6ea1f93eSDaniel Fojt
3530*6ea1f93eSDaniel Fojt'-C LINES'
3531*6ea1f93eSDaniel Fojt'--context[=LINES]'
3532008e37b6SJohn Marino     Use the context output format, showing LINES (an integer) lines of
3533008e37b6SJohn Marino     context, or three if LINES is not given.  *Note Context Format::.
3534*6ea1f93eSDaniel Fojt     For proper operation, 'patch' typically needs at least two lines of
3535008e37b6SJohn Marino     context.
3536008e37b6SJohn Marino
3537*6ea1f93eSDaniel Fojt     For compatibility 'diff' also supports an obsolete option syntax
3538*6ea1f93eSDaniel Fojt     '-LINES' that has effect when combined with '-c', '-p', or '-u'.
3539*6ea1f93eSDaniel Fojt     New scripts should use '-U LINES' ('-C LINES') instead.
3540008e37b6SJohn Marino
3541*6ea1f93eSDaniel Fojt'--changed-group-format=FORMAT'
3542008e37b6SJohn Marino     Use FORMAT to output a line group containing differing lines from
3543008e37b6SJohn Marino     both files in if-then-else format.  *Note Line Group Formats::.
3544008e37b6SJohn Marino
3545*6ea1f93eSDaniel Fojt'-d'
3546*6ea1f93eSDaniel Fojt'--minimal'
3547008e37b6SJohn Marino     Change the algorithm perhaps find a smaller set of changes.  This
3548*6ea1f93eSDaniel Fojt     makes 'diff' slower (sometimes much slower).  *Note diff
3549008e37b6SJohn Marino     Performance::.
3550008e37b6SJohn Marino
3551*6ea1f93eSDaniel Fojt'-D NAME'
3552*6ea1f93eSDaniel Fojt'--ifdef=NAME'
3553*6ea1f93eSDaniel Fojt     Make merged '#ifdef' format output, conditional on the preprocessor
3554008e37b6SJohn Marino     macro NAME.  *Note If-then-else::.
3555008e37b6SJohn Marino
3556*6ea1f93eSDaniel Fojt'-e'
3557*6ea1f93eSDaniel Fojt'--ed'
3558*6ea1f93eSDaniel Fojt     Make output that is a valid 'ed' script.  *Note ed Scripts::.
3559008e37b6SJohn Marino
3560*6ea1f93eSDaniel Fojt'-E'
3561*6ea1f93eSDaniel Fojt'--ignore-tab-expansion'
3562008e37b6SJohn Marino     Ignore changes due to tab expansion.  *Note White Space::.
3563008e37b6SJohn Marino
3564*6ea1f93eSDaniel Fojt'-f'
3565*6ea1f93eSDaniel Fojt'--forward-ed'
3566*6ea1f93eSDaniel Fojt     Make output that looks vaguely like an 'ed' script but has changes
3567008e37b6SJohn Marino     in the order they appear in the file.  *Note Forward ed::.
3568008e37b6SJohn Marino
3569*6ea1f93eSDaniel Fojt'-F REGEXP'
3570*6ea1f93eSDaniel Fojt'--show-function-line=REGEXP'
3571008e37b6SJohn Marino     In context and unified format, for each hunk of differences, show
3572008e37b6SJohn Marino     some of the last preceding line that matches REGEXP.  *Note
3573008e37b6SJohn Marino     Specified Headings::.
3574008e37b6SJohn Marino
3575*6ea1f93eSDaniel Fojt'--from-file=FILE'
3576008e37b6SJohn Marino     Compare FILE to each operand; FILE may be a directory.
3577008e37b6SJohn Marino
3578*6ea1f93eSDaniel Fojt'--help'
3579008e37b6SJohn Marino     Output a summary of usage and then exit.
3580008e37b6SJohn Marino
3581*6ea1f93eSDaniel Fojt'--horizon-lines=LINES'
3582008e37b6SJohn Marino     Do not discard the last LINES lines of the common prefix and the
3583008e37b6SJohn Marino     first LINES lines of the common suffix.  *Note diff Performance::.
3584008e37b6SJohn Marino
3585*6ea1f93eSDaniel Fojt'-i'
3586*6ea1f93eSDaniel Fojt'--ignore-case'
3587008e37b6SJohn Marino     Ignore changes in case; consider upper- and lower-case letters
3588008e37b6SJohn Marino     equivalent.  *Note Case Folding::.
3589008e37b6SJohn Marino
3590*6ea1f93eSDaniel Fojt'-I REGEXP'
3591*6ea1f93eSDaniel Fojt'--ignore-matching-lines=REGEXP'
3592008e37b6SJohn Marino     Ignore changes that just insert or delete lines that match REGEXP.
3593008e37b6SJohn Marino     *Note Specified Lines::.
3594008e37b6SJohn Marino
3595*6ea1f93eSDaniel Fojt'--ignore-file-name-case'
3596008e37b6SJohn Marino     Ignore case when comparing file names.  For example, recursive
3597*6ea1f93eSDaniel Fojt     comparison of 'd' to 'e' might compare the contents of 'd/Init' and
3598*6ea1f93eSDaniel Fojt     'e/inIt'.  At the top level, 'diff d inIt' might compare the
3599*6ea1f93eSDaniel Fojt     contents of 'd/Init' and 'inIt'.  *Note Comparing Directories::.
3600008e37b6SJohn Marino
3601*6ea1f93eSDaniel Fojt'-l'
3602*6ea1f93eSDaniel Fojt'--paginate'
3603*6ea1f93eSDaniel Fojt     Pass the output through 'pr' to paginate it.  *Note Pagination::.
3604008e37b6SJohn Marino
3605*6ea1f93eSDaniel Fojt'-L LABEL'
3606*6ea1f93eSDaniel Fojt'--label=LABEL'
3607008e37b6SJohn Marino     Use LABEL instead of the file name in the context format (*note
3608008e37b6SJohn Marino     Context Format::) and unified format (*note Unified Format::)
3609008e37b6SJohn Marino     headers.  *Note RCS::.
3610008e37b6SJohn Marino
3611*6ea1f93eSDaniel Fojt'--left-column'
3612008e37b6SJohn Marino     Print only the left column of two common lines in side by side
3613008e37b6SJohn Marino     format.  *Note Side by Side Format::.
3614008e37b6SJohn Marino
3615*6ea1f93eSDaniel Fojt'--line-format=FORMAT'
3616*6ea1f93eSDaniel Fojt     Use FORMAT to output all input lines in if-then-else format.  *Note
3617*6ea1f93eSDaniel Fojt     Line Formats::.
3618008e37b6SJohn Marino
3619*6ea1f93eSDaniel Fojt'-n'
3620*6ea1f93eSDaniel Fojt'--rcs'
3621*6ea1f93eSDaniel Fojt     Output RCS-format diffs; like '-f' except that each command
3622008e37b6SJohn Marino     specifies the number of lines affected.  *Note RCS::.
3623008e37b6SJohn Marino
3624*6ea1f93eSDaniel Fojt'-N'
3625*6ea1f93eSDaniel Fojt'--new-file'
36264536c563SJohn Marino     If one file is missing, treat it as present but empty.  *Note
3627008e37b6SJohn Marino     Comparing Directories::.
3628008e37b6SJohn Marino
3629*6ea1f93eSDaniel Fojt'--new-group-format=FORMAT'
3630008e37b6SJohn Marino     Use FORMAT to output a group of lines taken from just the second
3631008e37b6SJohn Marino     file in if-then-else format.  *Note Line Group Formats::.
3632008e37b6SJohn Marino
3633*6ea1f93eSDaniel Fojt'--new-line-format=FORMAT'
3634008e37b6SJohn Marino     Use FORMAT to output a line taken from just the second file in
3635008e37b6SJohn Marino     if-then-else format.  *Note Line Formats::.
3636008e37b6SJohn Marino
3637*6ea1f93eSDaniel Fojt'--no-dereference'
36384536c563SJohn Marino     Act on symbolic links themselves instead of what they point to.
3639*6ea1f93eSDaniel Fojt     Two symbolic links are deemed equal only when each points to
3640*6ea1f93eSDaniel Fojt     precisely the same name.
36414536c563SJohn Marino
3642*6ea1f93eSDaniel Fojt'--old-group-format=FORMAT'
3643008e37b6SJohn Marino     Use FORMAT to output a group of lines taken from just the first
3644008e37b6SJohn Marino     file in if-then-else format.  *Note Line Group Formats::.
3645008e37b6SJohn Marino
3646*6ea1f93eSDaniel Fojt'--old-line-format=FORMAT'
3647008e37b6SJohn Marino     Use FORMAT to output a line taken from just the first file in
3648008e37b6SJohn Marino     if-then-else format.  *Note Line Formats::.
3649008e37b6SJohn Marino
3650*6ea1f93eSDaniel Fojt'-p'
3651*6ea1f93eSDaniel Fojt'--show-c-function'
3652008e37b6SJohn Marino     Show which C function each change is in.  *Note C Function
3653008e37b6SJohn Marino     Headings::.
3654008e37b6SJohn Marino
3655*6ea1f93eSDaniel Fojt'--palette=PALETTE'
3656*6ea1f93eSDaniel Fojt     Specify what color palette to use when colored output is enabled.
3657*6ea1f93eSDaniel Fojt     It defaults to 'rs=0:hd=1:ad=32:de=31:ln=36' for red deleted lines,
3658*6ea1f93eSDaniel Fojt     green added lines, cyan line numbers, bold header.
3659*6ea1f93eSDaniel Fojt
3660*6ea1f93eSDaniel Fojt     Supported capabilities are as follows.
3661*6ea1f93eSDaniel Fojt
3662*6ea1f93eSDaniel Fojt     'ad=32'
3663*6ea1f93eSDaniel Fojt
3664*6ea1f93eSDaniel Fojt          SGR substring for added lines.  The default is green
3665*6ea1f93eSDaniel Fojt          foreground.
3666*6ea1f93eSDaniel Fojt
3667*6ea1f93eSDaniel Fojt     'de=31'
3668*6ea1f93eSDaniel Fojt
3669*6ea1f93eSDaniel Fojt          SGR substring for deleted lines.  The default is red
3670*6ea1f93eSDaniel Fojt          foreground.
3671*6ea1f93eSDaniel Fojt
3672*6ea1f93eSDaniel Fojt     'hd=1'
3673*6ea1f93eSDaniel Fojt
3674*6ea1f93eSDaniel Fojt          SGR substring for chunk header.  The default is bold
3675*6ea1f93eSDaniel Fojt          foreground.
3676*6ea1f93eSDaniel Fojt
3677*6ea1f93eSDaniel Fojt     'ln=36'
3678*6ea1f93eSDaniel Fojt
3679*6ea1f93eSDaniel Fojt          SGR substring for line numbers.  The default is cyan
3680*6ea1f93eSDaniel Fojt          foreground.
3681*6ea1f93eSDaniel Fojt
3682*6ea1f93eSDaniel Fojt'-q'
3683*6ea1f93eSDaniel Fojt'--brief'
3684008e37b6SJohn Marino     Report only whether the files differ, not the details of the
3685008e37b6SJohn Marino     differences.  *Note Brief::.
3686008e37b6SJohn Marino
3687*6ea1f93eSDaniel Fojt'-r'
3688*6ea1f93eSDaniel Fojt'--recursive'
3689008e37b6SJohn Marino     When comparing directories, recursively compare any subdirectories
3690008e37b6SJohn Marino     found.  *Note Comparing Directories::.
3691008e37b6SJohn Marino
3692*6ea1f93eSDaniel Fojt'-s'
3693*6ea1f93eSDaniel Fojt'--report-identical-files'
3694008e37b6SJohn Marino     Report when two files are the same.  *Note Comparing Directories::.
3695008e37b6SJohn Marino
3696*6ea1f93eSDaniel Fojt'-S FILE'
3697*6ea1f93eSDaniel Fojt'--starting-file=FILE'
3698*6ea1f93eSDaniel Fojt     When comparing directories, start with the file FILE.  This is used
3699*6ea1f93eSDaniel Fojt     for resuming an aborted comparison.  *Note Comparing Directories::.
3700008e37b6SJohn Marino
3701*6ea1f93eSDaniel Fojt'--speed-large-files'
3702008e37b6SJohn Marino     Use heuristics to speed handling of large files that have numerous
3703008e37b6SJohn Marino     scattered small changes.  *Note diff Performance::.
3704008e37b6SJohn Marino
3705*6ea1f93eSDaniel Fojt'--strip-trailing-cr'
3706008e37b6SJohn Marino     Strip any trailing carriage return at the end of an input line.
3707008e37b6SJohn Marino     *Note Binary::.
3708008e37b6SJohn Marino
3709*6ea1f93eSDaniel Fojt'--suppress-common-lines'
3710008e37b6SJohn Marino     Do not print common lines in side by side format.  *Note Side by
3711008e37b6SJohn Marino     Side Format::.
3712008e37b6SJohn Marino
3713*6ea1f93eSDaniel Fojt'-t'
3714*6ea1f93eSDaniel Fojt'--expand-tabs'
3715008e37b6SJohn Marino     Expand tabs to spaces in the output, to preserve the alignment of
3716008e37b6SJohn Marino     tabs in the input files.  *Note Tabs::.
3717008e37b6SJohn Marino
3718*6ea1f93eSDaniel Fojt'-T'
3719*6ea1f93eSDaniel Fojt'--initial-tab'
3720008e37b6SJohn Marino     Output a tab rather than a space before the text of a line in
3721*6ea1f93eSDaniel Fojt     normal or context format.  This causes the alignment of tabs in the
3722*6ea1f93eSDaniel Fojt     line to look normal.  *Note Tabs::.
3723008e37b6SJohn Marino
3724*6ea1f93eSDaniel Fojt'--tabsize=COLUMNS'
3725008e37b6SJohn Marino     Assume that tab stops are set every COLUMNS (default 8) print
3726008e37b6SJohn Marino     columns.  *Note Tabs::.
3727008e37b6SJohn Marino
3728*6ea1f93eSDaniel Fojt'--suppress-blank-empty'
3729008e37b6SJohn Marino     Suppress any blanks before newlines when printing the
3730008e37b6SJohn Marino     representation of an empty line, when outputting normal, context,
3731008e37b6SJohn Marino     or unified format.  *Note Trailing Blanks::.
3732008e37b6SJohn Marino
3733*6ea1f93eSDaniel Fojt'--to-file=FILE'
3734008e37b6SJohn Marino     Compare each operand to FILE; FILE may be a directory.
3735008e37b6SJohn Marino
3736*6ea1f93eSDaniel Fojt'-u'
3737008e37b6SJohn Marino     Use the unified output format, showing three lines of context.
3738008e37b6SJohn Marino     *Note Unified Format::.
3739008e37b6SJohn Marino
3740*6ea1f93eSDaniel Fojt'--unchanged-group-format=FORMAT'
3741008e37b6SJohn Marino     Use FORMAT to output a group of common lines taken from both files
3742008e37b6SJohn Marino     in if-then-else format.  *Note Line Group Formats::.
3743008e37b6SJohn Marino
3744*6ea1f93eSDaniel Fojt'--unchanged-line-format=FORMAT'
3745008e37b6SJohn Marino     Use FORMAT to output a line common to both files in if-then-else
3746008e37b6SJohn Marino     format.  *Note Line Formats::.
3747008e37b6SJohn Marino
3748*6ea1f93eSDaniel Fojt'--unidirectional-new-file'
37494536c563SJohn Marino     If a first file is missing, treat it as present but empty.  *Note
37504536c563SJohn Marino     Comparing Directories::.
3751008e37b6SJohn Marino
3752*6ea1f93eSDaniel Fojt'-U LINES'
3753*6ea1f93eSDaniel Fojt'--unified[=LINES]'
3754008e37b6SJohn Marino     Use the unified output format, showing LINES (an integer) lines of
3755008e37b6SJohn Marino     context, or three if LINES is not given.  *Note Unified Format::.
3756*6ea1f93eSDaniel Fojt     For proper operation, 'patch' typically needs at least two lines of
3757008e37b6SJohn Marino     context.
3758008e37b6SJohn Marino
3759*6ea1f93eSDaniel Fojt     On older systems, 'diff' supports an obsolete option '-LINES' that
3760*6ea1f93eSDaniel Fojt     has effect when combined with '-u'.  POSIX 1003.1-2001 (*note
3761*6ea1f93eSDaniel Fojt     Standards conformance::) does not allow this; use '-U LINES'
3762008e37b6SJohn Marino     instead.
3763008e37b6SJohn Marino
3764*6ea1f93eSDaniel Fojt'-v'
3765*6ea1f93eSDaniel Fojt'--version'
3766008e37b6SJohn Marino     Output version information and then exit.
3767008e37b6SJohn Marino
3768*6ea1f93eSDaniel Fojt'-w'
3769*6ea1f93eSDaniel Fojt'--ignore-all-space'
3770008e37b6SJohn Marino     Ignore white space when comparing lines.  *Note White Space::.
3771008e37b6SJohn Marino
3772*6ea1f93eSDaniel Fojt'-W COLUMNS'
3773*6ea1f93eSDaniel Fojt'--width=COLUMNS'
3774*6ea1f93eSDaniel Fojt     Output at most COLUMNS (default 130) print columns per line in side
3775*6ea1f93eSDaniel Fojt     by side format.  *Note Side by Side Format::.
3776008e37b6SJohn Marino
3777*6ea1f93eSDaniel Fojt'-x PATTERN'
3778*6ea1f93eSDaniel Fojt'--exclude=PATTERN'
3779008e37b6SJohn Marino     When comparing directories, ignore files and subdirectories whose
3780008e37b6SJohn Marino     basenames match PATTERN.  *Note Comparing Directories::.
3781008e37b6SJohn Marino
3782*6ea1f93eSDaniel Fojt'-X FILE'
3783*6ea1f93eSDaniel Fojt'--exclude-from=FILE'
3784008e37b6SJohn Marino     When comparing directories, ignore files and subdirectories whose
3785008e37b6SJohn Marino     basenames match any pattern contained in FILE.  *Note Comparing
3786008e37b6SJohn Marino     Directories::.
3787008e37b6SJohn Marino
3788*6ea1f93eSDaniel Fojt'-y'
3789*6ea1f93eSDaniel Fojt'--side-by-side'
3790008e37b6SJohn Marino     Use the side by side output format.  *Note Side by Side Format::.
3791008e37b6SJohn Marino
3792*6ea1f93eSDaniel Fojt'-Z'
3793*6ea1f93eSDaniel Fojt'--ignore-trailing-space'
3794008e37b6SJohn Marino     Ignore white space at line end.  *Note White Space::.
3795008e37b6SJohn Marino
3796008e37b6SJohn Marino
3797*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Invoking diff3,  Next: Invoking patch,  Prev: Invoking diff,  Up: Top
3798008e37b6SJohn Marino
3799*6ea1f93eSDaniel Fojt14 Invoking 'diff3'
3800008e37b6SJohn Marino*******************
3801008e37b6SJohn Marino
3802*6ea1f93eSDaniel FojtThe 'diff3' command compares three files and outputs descriptions of
3803008e37b6SJohn Marinotheir differences.  Its arguments are as follows:
3804008e37b6SJohn Marino
3805008e37b6SJohn Marino     diff3 OPTIONS... MINE OLDER YOURS
3806008e37b6SJohn Marino
3807008e37b6SJohn Marino   The files to compare are MINE, OLDER, and YOURS.  At most one of
3808*6ea1f93eSDaniel Fojtthese three file names may be '-', which tells 'diff3' to read the
3809008e37b6SJohn Marinostandard input for that file.
3810008e37b6SJohn Marino
3811*6ea1f93eSDaniel Fojt   An exit status of 0 means 'diff3' was successful, 1 means some
3812008e37b6SJohn Marinoconflicts were found, and 2 means trouble.
3813008e37b6SJohn Marino
3814008e37b6SJohn Marino* Menu:
3815008e37b6SJohn Marino
3816*6ea1f93eSDaniel Fojt* diff3 Options:: Summary of options to 'diff3'.
3817008e37b6SJohn Marino
3818008e37b6SJohn Marino
3819*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: diff3 Options,  Up: Invoking diff3
3820008e37b6SJohn Marino
3821*6ea1f93eSDaniel Fojt14.1 Options to 'diff3'
3822008e37b6SJohn Marino=======================
3823008e37b6SJohn Marino
3824*6ea1f93eSDaniel FojtBelow is a summary of all of the options that GNU 'diff3' accepts.
3825008e37b6SJohn MarinoMultiple single letter options (unless they take an argument) can be
3826008e37b6SJohn Marinocombined into a single command line argument.
3827008e37b6SJohn Marino
3828*6ea1f93eSDaniel Fojt'-a'
3829*6ea1f93eSDaniel Fojt'--text'
3830008e37b6SJohn Marino     Treat all files as text and compare them line-by-line, even if they
3831008e37b6SJohn Marino     do not appear to be text.  *Note Binary::.
3832008e37b6SJohn Marino
3833*6ea1f93eSDaniel Fojt'-A'
3834*6ea1f93eSDaniel Fojt'--show-all'
3835008e37b6SJohn Marino     Incorporate all unmerged changes from OLDER to YOURS into MINE,
3836008e37b6SJohn Marino     surrounding conflicts with bracket lines.  *Note Marking
3837008e37b6SJohn Marino     Conflicts::.
3838008e37b6SJohn Marino
3839*6ea1f93eSDaniel Fojt'--diff-program=PROGRAM'
3840008e37b6SJohn Marino     Use the compatible comparison program PROGRAM to compare files
3841*6ea1f93eSDaniel Fojt     instead of 'diff'.
3842008e37b6SJohn Marino
3843*6ea1f93eSDaniel Fojt'-e'
3844*6ea1f93eSDaniel Fojt'--ed'
3845*6ea1f93eSDaniel Fojt     Generate an 'ed' script that incorporates all the changes from
3846008e37b6SJohn Marino     OLDER to YOURS into MINE.  *Note Which Changes::.
3847008e37b6SJohn Marino
3848*6ea1f93eSDaniel Fojt'-E'
3849*6ea1f93eSDaniel Fojt'--show-overlap'
3850*6ea1f93eSDaniel Fojt     Like '-e', except bracket lines from overlapping changes' first and
3851*6ea1f93eSDaniel Fojt     third files.  *Note Marking Conflicts::.  With '-E', an overlapping
3852*6ea1f93eSDaniel Fojt     change looks like this:
3853008e37b6SJohn Marino
3854008e37b6SJohn Marino          <<<<<<< MINE
3855008e37b6SJohn Marino          lines from MINE
3856008e37b6SJohn Marino          =======
3857008e37b6SJohn Marino          lines from YOURS
3858008e37b6SJohn Marino          >>>>>>> YOURS
3859008e37b6SJohn Marino
3860*6ea1f93eSDaniel Fojt'--help'
3861008e37b6SJohn Marino     Output a summary of usage and then exit.
3862008e37b6SJohn Marino
3863*6ea1f93eSDaniel Fojt'-i'
3864*6ea1f93eSDaniel Fojt     Generate 'w' and 'q' commands at the end of the 'ed' script for
3865008e37b6SJohn Marino     System V compatibility.  This option must be combined with one of
3866*6ea1f93eSDaniel Fojt     the '-AeExX3' options, and may not be combined with '-m'.  *Note
3867008e37b6SJohn Marino     Saving the Changed File::.
3868008e37b6SJohn Marino
3869*6ea1f93eSDaniel Fojt'--label=LABEL'
3870*6ea1f93eSDaniel Fojt     Use the label LABEL for the brackets output by the '-A', '-E' and
3871*6ea1f93eSDaniel Fojt     '-X' options.  This option may be given up to three times, one for
3872008e37b6SJohn Marino     each input file.  The default labels are the names of the input
3873*6ea1f93eSDaniel Fojt     files.  Thus 'diff3 --label X --label Y --label Z -m A B C' acts
3874*6ea1f93eSDaniel Fojt     like 'diff3 -m A B C', except that the output looks like it came
3875*6ea1f93eSDaniel Fojt     from files named 'X', 'Y' and 'Z' rather than from files named 'A',
3876*6ea1f93eSDaniel Fojt     'B' and 'C'.  *Note Marking Conflicts::.
3877008e37b6SJohn Marino
3878*6ea1f93eSDaniel Fojt'-m'
3879*6ea1f93eSDaniel Fojt'--merge'
3880008e37b6SJohn Marino     Apply the edit script to the first file and send the result to
3881*6ea1f93eSDaniel Fojt     standard output.  Unlike piping the output from 'diff3' to 'ed',
3882*6ea1f93eSDaniel Fojt     this works even for binary files and incomplete lines.  '-A' is
3883008e37b6SJohn Marino     assumed if no edit script option is specified.  *Note Bypassing
3884008e37b6SJohn Marino     ed::.
3885008e37b6SJohn Marino
3886*6ea1f93eSDaniel Fojt'--strip-trailing-cr'
3887008e37b6SJohn Marino     Strip any trailing carriage return at the end of an input line.
3888008e37b6SJohn Marino     *Note Binary::.
3889008e37b6SJohn Marino
3890*6ea1f93eSDaniel Fojt'-T'
3891*6ea1f93eSDaniel Fojt'--initial-tab'
3892008e37b6SJohn Marino     Output a tab rather than two spaces before the text of a line in
3893008e37b6SJohn Marino     normal format.  This causes the alignment of tabs in the line to
3894008e37b6SJohn Marino     look normal.  *Note Tabs::.
3895008e37b6SJohn Marino
3896*6ea1f93eSDaniel Fojt'-v'
3897*6ea1f93eSDaniel Fojt'--version'
3898008e37b6SJohn Marino     Output version information and then exit.
3899008e37b6SJohn Marino
3900*6ea1f93eSDaniel Fojt'-x'
3901*6ea1f93eSDaniel Fojt'--overlap-only'
3902*6ea1f93eSDaniel Fojt     Like '-e', except output only the overlapping changes.  *Note Which
3903*6ea1f93eSDaniel Fojt     Changes::.
3904008e37b6SJohn Marino
3905*6ea1f93eSDaniel Fojt'-X'
3906*6ea1f93eSDaniel Fojt     Like '-E', except output only the overlapping changes.  In other
3907*6ea1f93eSDaniel Fojt     words, like '-x', except bracket changes as in '-E'.  *Note Marking
3908*6ea1f93eSDaniel Fojt     Conflicts::.
3909008e37b6SJohn Marino
3910*6ea1f93eSDaniel Fojt'-3'
3911*6ea1f93eSDaniel Fojt'--easy-only'
3912*6ea1f93eSDaniel Fojt     Like '-e', except output only the nonoverlapping changes.  *Note
3913008e37b6SJohn Marino     Which Changes::.
3914008e37b6SJohn Marino
3915008e37b6SJohn Marino
3916*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Invoking patch,  Next: Invoking sdiff,  Prev: Invoking diff3,  Up: Top
3917008e37b6SJohn Marino
3918*6ea1f93eSDaniel Fojt15 Invoking 'patch'
3919008e37b6SJohn Marino*******************
3920008e37b6SJohn Marino
3921*6ea1f93eSDaniel FojtNormally 'patch' is invoked like this:
3922008e37b6SJohn Marino
3923008e37b6SJohn Marino     patch <PATCHFILE
3924008e37b6SJohn Marino
3925*6ea1f93eSDaniel Fojt   The full format for invoking 'patch' is:
3926008e37b6SJohn Marino
3927008e37b6SJohn Marino     patch OPTIONS... [ORIGFILE [PATCHFILE]]
3928008e37b6SJohn Marino
3929*6ea1f93eSDaniel Fojt   You can also specify where to read the patch from with the '-i
3930*6ea1f93eSDaniel FojtPATCHFILE' or '--input=PATCHFILE' option.  If you do not specify
3931*6ea1f93eSDaniel FojtPATCHFILE, or if PATCHFILE is '-', 'patch' reads the patch (that is, the
3932*6ea1f93eSDaniel Fojt'diff' output) from the standard input.
3933008e37b6SJohn Marino
3934*6ea1f93eSDaniel Fojt   If you do not specify an input file on the command line, 'patch'
3935008e37b6SJohn Marinotries to intuit from the "leading text" (any text in the patch that
3936*6ea1f93eSDaniel Fojtcomes before the 'diff' output) which file to edit.  *Note Multiple
3937008e37b6SJohn MarinoPatches::.
3938008e37b6SJohn Marino
3939*6ea1f93eSDaniel Fojt   By default, 'patch' replaces the original input file with the patched
3940*6ea1f93eSDaniel Fojtversion, possibly after renaming the original file into a backup file
3941*6ea1f93eSDaniel Fojt(*note Backup Names::, for a description of how 'patch' names backup
3942*6ea1f93eSDaniel Fojtfiles).  You can also specify where to put the output with the '-o FILE'
3943*6ea1f93eSDaniel Fojtor '--output=FILE' option; however, do not use this option if FILE is
3944*6ea1f93eSDaniel Fojtone of the input files.
3945008e37b6SJohn Marino
3946008e37b6SJohn Marino* Menu:
3947008e37b6SJohn Marino
3948*6ea1f93eSDaniel Fojt* patch Options::     Summary table of options to 'patch'.
3949008e37b6SJohn Marino
3950008e37b6SJohn Marino
3951*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: patch Options,  Up: Invoking patch
3952008e37b6SJohn Marino
3953*6ea1f93eSDaniel Fojt15.1 Options to 'patch'
3954008e37b6SJohn Marino=======================
3955008e37b6SJohn Marino
3956*6ea1f93eSDaniel FojtHere is a summary of all of the options that GNU 'patch' accepts.  *Note
3957*6ea1f93eSDaniel Fojtpatch and Tradition::, for which of these options are safe to use in
3958*6ea1f93eSDaniel Fojtolder versions of 'patch'.
3959008e37b6SJohn Marino
3960008e37b6SJohn Marino   Multiple single-letter options that do not take an argument can be
3961008e37b6SJohn Marinocombined into a single command line argument with only one dash.
3962008e37b6SJohn Marino
3963*6ea1f93eSDaniel Fojt'-b'
3964*6ea1f93eSDaniel Fojt'--backup'
3965008e37b6SJohn Marino     Back up the original contents of each file, even if backups would
3966008e37b6SJohn Marino     normally not be made.  *Note Backups::.
3967008e37b6SJohn Marino
3968*6ea1f93eSDaniel Fojt'-B PREFIX'
3969*6ea1f93eSDaniel Fojt'--prefix=PREFIX'
3970008e37b6SJohn Marino     Prepend PREFIX to backup file names.  *Note Backup Names::.
3971008e37b6SJohn Marino
3972*6ea1f93eSDaniel Fojt'--backup-if-mismatch'
3973008e37b6SJohn Marino     Back up the original contents of each file if the patch does not
3974008e37b6SJohn Marino     exactly match the file.  This is the default behavior when not
3975008e37b6SJohn Marino     conforming to POSIX. *Note Backups::.
3976008e37b6SJohn Marino
3977*6ea1f93eSDaniel Fojt'--binary'
3978008e37b6SJohn Marino     Read and write all files in binary mode, except for standard output
3979*6ea1f93eSDaniel Fojt     and '/dev/tty'.  This option has no effect on POSIX-conforming
3980008e37b6SJohn Marino     systems like GNU/Linux.  On systems where this option makes a
3981*6ea1f93eSDaniel Fojt     difference, the patch should be generated by 'diff -a --binary'.
3982008e37b6SJohn Marino     *Note Binary::.
3983008e37b6SJohn Marino
3984*6ea1f93eSDaniel Fojt'-c'
3985*6ea1f93eSDaniel Fojt'--context'
3986008e37b6SJohn Marino     Interpret the patch file as a context diff.  *Note patch Input::.
3987008e37b6SJohn Marino
3988*6ea1f93eSDaniel Fojt'-d DIRECTORY'
3989*6ea1f93eSDaniel Fojt'--directory=DIRECTORY'
3990008e37b6SJohn Marino     Make directory DIRECTORY the current directory for interpreting
3991008e37b6SJohn Marino     both file names in the patch file, and file names given as
3992008e37b6SJohn Marino     arguments to other options.  *Note patch Directories::.
3993008e37b6SJohn Marino
3994*6ea1f93eSDaniel Fojt'-D NAME'
3995*6ea1f93eSDaniel Fojt'--ifdef=NAME'
3996008e37b6SJohn Marino     Make merged if-then-else output using NAME.  *Note If-then-else::.
3997008e37b6SJohn Marino
3998*6ea1f93eSDaniel Fojt'--dry-run'
3999008e37b6SJohn Marino     Print the results of applying the patches without actually changing
4000008e37b6SJohn Marino     any files.  *Note Dry Runs::.
4001008e37b6SJohn Marino
4002*6ea1f93eSDaniel Fojt'-e'
4003*6ea1f93eSDaniel Fojt'--ed'
4004*6ea1f93eSDaniel Fojt     Interpret the patch file as an 'ed' script.  *Note patch Input::.
4005008e37b6SJohn Marino
4006*6ea1f93eSDaniel Fojt'-E'
4007*6ea1f93eSDaniel Fojt'--remove-empty-files'
4008008e37b6SJohn Marino     Remove output files that are empty after the patches have been
4009008e37b6SJohn Marino     applied.  *Note Creating and Removing::.
4010008e37b6SJohn Marino
4011*6ea1f93eSDaniel Fojt'-f'
4012*6ea1f93eSDaniel Fojt'--force'
4013008e37b6SJohn Marino     Assume that the user knows exactly what he or she is doing, and do
4014008e37b6SJohn Marino     not ask any questions.  *Note patch Messages::.
4015008e37b6SJohn Marino
4016*6ea1f93eSDaniel Fojt'-F LINES'
4017*6ea1f93eSDaniel Fojt'--fuzz=LINES'
4018008e37b6SJohn Marino     Set the maximum fuzz factor to LINES.  *Note Inexact::.
4019008e37b6SJohn Marino
4020*6ea1f93eSDaniel Fojt'-g NUM'
4021*6ea1f93eSDaniel Fojt'--get=NUM'
4022008e37b6SJohn Marino     If NUM is positive, get input files from a revision control system
4023008e37b6SJohn Marino     as necessary; if zero, do not get the files; if negative, ask the
4024008e37b6SJohn Marino     user whether to get the files.  *Note Revision Control::.
4025008e37b6SJohn Marino
4026*6ea1f93eSDaniel Fojt'--help'
4027008e37b6SJohn Marino     Output a summary of usage and then exit.
4028008e37b6SJohn Marino
4029*6ea1f93eSDaniel Fojt'-i PATCHFILE'
4030*6ea1f93eSDaniel Fojt'--input=PATCHFILE'
4031008e37b6SJohn Marino     Read the patch from PATCHFILE rather than from standard input.
4032008e37b6SJohn Marino     *Note patch Options::.
4033008e37b6SJohn Marino
4034*6ea1f93eSDaniel Fojt'-l'
4035*6ea1f93eSDaniel Fojt'--ignore-white-space'
4036008e37b6SJohn Marino     Let any sequence of blanks (spaces or tabs) in the patch file match
4037008e37b6SJohn Marino     any sequence of blanks in the input file.  *Note Changed White
4038008e37b6SJohn Marino     Space::.
4039008e37b6SJohn Marino
4040*6ea1f93eSDaniel Fojt'-n'
4041*6ea1f93eSDaniel Fojt'--normal'
4042008e37b6SJohn Marino     Interpret the patch file as a normal diff.  *Note patch Input::.
4043008e37b6SJohn Marino
4044*6ea1f93eSDaniel Fojt'-N'
4045*6ea1f93eSDaniel Fojt'--forward'
4046*6ea1f93eSDaniel Fojt     Ignore patches that 'patch' thinks are reversed or already applied.
4047*6ea1f93eSDaniel Fojt     See also '-R'.  *Note Reversed Patches::.
4048008e37b6SJohn Marino
4049*6ea1f93eSDaniel Fojt'--no-backup-if-mismatch'
4050008e37b6SJohn Marino     Do not back up the original contents of files.  This is the default
4051008e37b6SJohn Marino     behavior when conforming to POSIX. *Note Backups::.
4052008e37b6SJohn Marino
4053*6ea1f93eSDaniel Fojt'-o FILE'
4054*6ea1f93eSDaniel Fojt'--output=FILE'
4055008e37b6SJohn Marino     Use FILE as the output file name.  *Note patch Options::.
4056008e37b6SJohn Marino
4057*6ea1f93eSDaniel Fojt'-pNUMBER'
4058*6ea1f93eSDaniel Fojt'--strip=NUMBER'
4059008e37b6SJohn Marino     Set the file name strip count to NUMBER.  *Note patch
4060008e37b6SJohn Marino     Directories::.
4061008e37b6SJohn Marino
4062*6ea1f93eSDaniel Fojt'--posix'
4063*6ea1f93eSDaniel Fojt     Conform to POSIX, as if the 'POSIXLY_CORRECT' environment variable
4064008e37b6SJohn Marino     had been set.  *Note patch and POSIX::.
4065008e37b6SJohn Marino
4066*6ea1f93eSDaniel Fojt'--quoting-style=WORD'
4067008e37b6SJohn Marino     Use style WORD to quote names in diagnostics, as if the
4068*6ea1f93eSDaniel Fojt     'QUOTING_STYLE' environment variable had been set to WORD.  *Note
4069008e37b6SJohn Marino     patch Quoting Style::.
4070008e37b6SJohn Marino
4071*6ea1f93eSDaniel Fojt'-r REJECT-FILE'
4072*6ea1f93eSDaniel Fojt'--reject-file=REJECT-FILE'
4073008e37b6SJohn Marino     Use REJECT-FILE as the reject file name.  *Note Reject Names::.
4074008e37b6SJohn Marino
4075*6ea1f93eSDaniel Fojt'-R'
4076*6ea1f93eSDaniel Fojt'--reverse'
4077008e37b6SJohn Marino     Assume that this patch was created with the old and new files
4078008e37b6SJohn Marino     swapped.  *Note Reversed Patches::.
4079008e37b6SJohn Marino
4080*6ea1f93eSDaniel Fojt'-s'
4081*6ea1f93eSDaniel Fojt'--quiet'
4082*6ea1f93eSDaniel Fojt'--silent'
4083008e37b6SJohn Marino     Work silently unless an error occurs.  *Note patch Messages::.
4084008e37b6SJohn Marino
4085*6ea1f93eSDaniel Fojt'-t'
4086*6ea1f93eSDaniel Fojt'--batch'
4087008e37b6SJohn Marino     Do not ask any questions.  *Note patch Messages::.
4088008e37b6SJohn Marino
4089*6ea1f93eSDaniel Fojt'-T'
4090*6ea1f93eSDaniel Fojt'--set-time'
4091*6ea1f93eSDaniel Fojt     Set the modification and access times of patched files from
4092*6ea1f93eSDaniel Fojt     timestamps given in context diff headers, assuming that the context
4093*6ea1f93eSDaniel Fojt     diff headers use local time.  *Note Patching Timestamps::.
4094008e37b6SJohn Marino
4095*6ea1f93eSDaniel Fojt'-u'
4096*6ea1f93eSDaniel Fojt'--unified'
4097008e37b6SJohn Marino     Interpret the patch file as a unified diff.  *Note patch Input::.
4098008e37b6SJohn Marino
4099*6ea1f93eSDaniel Fojt'-v'
4100*6ea1f93eSDaniel Fojt'--version'
4101008e37b6SJohn Marino     Output version information and then exit.
4102008e37b6SJohn Marino
4103*6ea1f93eSDaniel Fojt'-V BACKUP-STYLE'
4104*6ea1f93eSDaniel Fojt'--version=control=BACKUP-STYLE'
4105008e37b6SJohn Marino     Select the naming convention for backup file names.  *Note Backup
4106008e37b6SJohn Marino     Names::.
4107008e37b6SJohn Marino
4108*6ea1f93eSDaniel Fojt'--verbose'
4109008e37b6SJohn Marino     Print more diagnostics than usual.  *Note patch Messages::.
4110008e37b6SJohn Marino
4111*6ea1f93eSDaniel Fojt'-x NUMBER'
4112*6ea1f93eSDaniel Fojt'--debug=NUMBER'
4113*6ea1f93eSDaniel Fojt     Set internal debugging flags.  Of interest only to 'patch'
4114008e37b6SJohn Marino     patchers.
4115008e37b6SJohn Marino
4116*6ea1f93eSDaniel Fojt'-Y PREFIX'
4117*6ea1f93eSDaniel Fojt'--basename-prefix=PREFIX'
4118008e37b6SJohn Marino     Prepend PREFIX to base names of backup files.  *Note Backup
4119008e37b6SJohn Marino     Names::.
4120008e37b6SJohn Marino
4121*6ea1f93eSDaniel Fojt'-z SUFFIX'
4122*6ea1f93eSDaniel Fojt'--suffix=SUFFIX'
4123*6ea1f93eSDaniel Fojt     Use SUFFIX as the backup extension instead of '.orig' or '~'.
4124008e37b6SJohn Marino     *Note Backup Names::.
4125008e37b6SJohn Marino
4126*6ea1f93eSDaniel Fojt'-Z'
4127*6ea1f93eSDaniel Fojt'--set-utc'
4128*6ea1f93eSDaniel Fojt     Set the modification and access times of patched files from
4129*6ea1f93eSDaniel Fojt     timestamps given in context diff headers, assuming that the context
4130*6ea1f93eSDaniel Fojt     diff headers use UTC. *Note Patching Timestamps::.
4131008e37b6SJohn Marino
4132008e37b6SJohn Marino
4133*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Invoking sdiff,  Next: Standards conformance,  Prev: Invoking patch,  Up: Top
4134008e37b6SJohn Marino
4135*6ea1f93eSDaniel Fojt16 Invoking 'sdiff'
4136008e37b6SJohn Marino*******************
4137008e37b6SJohn Marino
4138*6ea1f93eSDaniel FojtThe 'sdiff' command merges two files and interactively outputs the
4139008e37b6SJohn Marinoresults.  Its arguments are as follows:
4140008e37b6SJohn Marino
4141008e37b6SJohn Marino     sdiff -o OUTFILE OPTIONS... FROM-FILE TO-FILE
4142008e37b6SJohn Marino
4143008e37b6SJohn Marino   This merges FROM-FILE with TO-FILE, with output to OUTFILE.  If
4144*6ea1f93eSDaniel FojtFROM-FILE is a directory and TO-FILE is not, 'sdiff' compares the file
4145008e37b6SJohn Marinoin FROM-FILE whose file name is that of TO-FILE, and vice versa.
4146008e37b6SJohn MarinoFROM-FILE and TO-FILE may not both be directories.
4147008e37b6SJohn Marino
4148*6ea1f93eSDaniel Fojt   'sdiff' options begin with '-', so normally FROM-FILE and TO-FILE may
4149*6ea1f93eSDaniel Fojtnot begin with '-'.  However, '--' as an argument by itself treats the
4150*6ea1f93eSDaniel Fojtremaining arguments as file names even if they begin with '-'.  You may
4151*6ea1f93eSDaniel Fojtnot use '-' as an input file.
4152008e37b6SJohn Marino
4153*6ea1f93eSDaniel Fojt   'sdiff' without '--output' ('-o') produces a side-by-side difference.
4154*6ea1f93eSDaniel FojtThis usage is obsolete; use the '--side-by-side' ('-y') option of 'diff'
4155*6ea1f93eSDaniel Fojtinstead.
4156008e37b6SJohn Marino
4157008e37b6SJohn Marino   An exit status of 0 means no differences were found, 1 means some
4158008e37b6SJohn Marinodifferences were found, and 2 means trouble.
4159008e37b6SJohn Marino
4160008e37b6SJohn Marino* Menu:
4161008e37b6SJohn Marino
4162*6ea1f93eSDaniel Fojt* sdiff Options:: Summary of options to 'diff'.
4163008e37b6SJohn Marino
4164008e37b6SJohn Marino
4165*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: sdiff Options,  Up: Invoking sdiff
4166008e37b6SJohn Marino
4167*6ea1f93eSDaniel Fojt16.1 Options to 'sdiff'
4168008e37b6SJohn Marino=======================
4169008e37b6SJohn Marino
4170*6ea1f93eSDaniel FojtBelow is a summary of all of the options that GNU 'sdiff' accepts.  Each
4171*6ea1f93eSDaniel Fojtoption has two equivalent names, one of which is a single letter
4172*6ea1f93eSDaniel Fojtpreceded by '-', and the other of which is a long name preceded by '--'.
4173*6ea1f93eSDaniel FojtMultiple single letter options (unless they take an argument) can be
4174*6ea1f93eSDaniel Fojtcombined into a single command line argument.  Long named options can be
4175*6ea1f93eSDaniel Fojtabbreviated to any unique prefix of their name.
4176008e37b6SJohn Marino
4177*6ea1f93eSDaniel Fojt'-a'
4178*6ea1f93eSDaniel Fojt'--text'
4179008e37b6SJohn Marino     Treat all files as text and compare them line-by-line, even if they
4180008e37b6SJohn Marino     do not appear to be text.  *Note Binary::.
4181008e37b6SJohn Marino
4182*6ea1f93eSDaniel Fojt'-b'
4183*6ea1f93eSDaniel Fojt'--ignore-space-change'
4184008e37b6SJohn Marino     Ignore changes in amount of white space.  *Note White Space::.
4185008e37b6SJohn Marino
4186*6ea1f93eSDaniel Fojt'-B'
4187*6ea1f93eSDaniel Fojt'--ignore-blank-lines'
4188*6ea1f93eSDaniel Fojt     Ignore changes that just insert or delete blank lines.  *Note Blank
4189*6ea1f93eSDaniel Fojt     Lines::.
4190008e37b6SJohn Marino
4191*6ea1f93eSDaniel Fojt'-d'
4192*6ea1f93eSDaniel Fojt'--minimal'
4193008e37b6SJohn Marino     Change the algorithm to perhaps find a smaller set of changes.
4194*6ea1f93eSDaniel Fojt     This makes 'sdiff' slower (sometimes much slower).  *Note diff
4195008e37b6SJohn Marino     Performance::.
4196008e37b6SJohn Marino
4197*6ea1f93eSDaniel Fojt'--diff-program=PROGRAM'
4198008e37b6SJohn Marino     Use the compatible comparison program PROGRAM to compare files
4199*6ea1f93eSDaniel Fojt     instead of 'diff'.
4200008e37b6SJohn Marino
4201*6ea1f93eSDaniel Fojt'-E'
4202*6ea1f93eSDaniel Fojt'--ignore-tab-expansion'
4203008e37b6SJohn Marino     Ignore changes due to tab expansion.  *Note White Space::.
4204008e37b6SJohn Marino
4205*6ea1f93eSDaniel Fojt'--help'
4206008e37b6SJohn Marino     Output a summary of usage and then exit.
4207008e37b6SJohn Marino
4208*6ea1f93eSDaniel Fojt'-i'
4209*6ea1f93eSDaniel Fojt'--ignore-case'
4210008e37b6SJohn Marino     Ignore changes in case; consider upper- and lower-case to be the
4211008e37b6SJohn Marino     same.  *Note Case Folding::.
4212008e37b6SJohn Marino
4213*6ea1f93eSDaniel Fojt'-I REGEXP'
4214*6ea1f93eSDaniel Fojt'--ignore-matching-lines=REGEXP'
4215008e37b6SJohn Marino     Ignore changes that just insert or delete lines that match REGEXP.
4216008e37b6SJohn Marino     *Note Specified Lines::.
4217008e37b6SJohn Marino
4218*6ea1f93eSDaniel Fojt'-l'
4219*6ea1f93eSDaniel Fojt'--left-column'
4220*6ea1f93eSDaniel Fojt     Print only the left column of two common lines.  *Note Side by Side
4221*6ea1f93eSDaniel Fojt     Format::.
4222008e37b6SJohn Marino
4223*6ea1f93eSDaniel Fojt'-o FILE'
4224*6ea1f93eSDaniel Fojt'--output=FILE'
4225008e37b6SJohn Marino     Put merged output into FILE.  This option is required for merging.
4226008e37b6SJohn Marino
4227*6ea1f93eSDaniel Fojt'-s'
4228*6ea1f93eSDaniel Fojt'--suppress-common-lines'
4229008e37b6SJohn Marino     Do not print common lines.  *Note Side by Side Format::.
4230008e37b6SJohn Marino
4231*6ea1f93eSDaniel Fojt'--speed-large-files'
4232008e37b6SJohn Marino     Use heuristics to speed handling of large files that have numerous
4233008e37b6SJohn Marino     scattered small changes.  *Note diff Performance::.
4234008e37b6SJohn Marino
4235*6ea1f93eSDaniel Fojt'--strip-trailing-cr'
4236008e37b6SJohn Marino     Strip any trailing carriage return at the end of an input line.
4237008e37b6SJohn Marino     *Note Binary::.
4238008e37b6SJohn Marino
4239*6ea1f93eSDaniel Fojt'-t'
4240*6ea1f93eSDaniel Fojt'--expand-tabs'
4241008e37b6SJohn Marino     Expand tabs to spaces in the output, to preserve the alignment of
4242008e37b6SJohn Marino     tabs in the input files.  *Note Tabs::.
4243008e37b6SJohn Marino
4244*6ea1f93eSDaniel Fojt'--tabsize=COLUMNS'
4245008e37b6SJohn Marino     Assume that tab stops are set every COLUMNS (default 8) print
4246008e37b6SJohn Marino     columns.  *Note Tabs::.
4247008e37b6SJohn Marino
4248*6ea1f93eSDaniel Fojt'-v'
4249*6ea1f93eSDaniel Fojt'--version'
4250008e37b6SJohn Marino     Output version information and then exit.
4251008e37b6SJohn Marino
4252*6ea1f93eSDaniel Fojt'-w COLUMNS'
4253*6ea1f93eSDaniel Fojt'--width=COLUMNS'
4254*6ea1f93eSDaniel Fojt     Output at most COLUMNS (default 130) print columns per line.  *Note
4255*6ea1f93eSDaniel Fojt     Side by Side Format::.  Note that for historical reasons, this
4256*6ea1f93eSDaniel Fojt     option is '-W' in 'diff', '-w' in 'sdiff'.
4257008e37b6SJohn Marino
4258*6ea1f93eSDaniel Fojt'-W'
4259*6ea1f93eSDaniel Fojt'--ignore-all-space'
4260008e37b6SJohn Marino     Ignore white space when comparing lines.  *Note White Space::.
4261*6ea1f93eSDaniel Fojt     Note that for historical reasons, this option is '-w' in 'diff',
4262*6ea1f93eSDaniel Fojt     '-W' in 'sdiff'.
4263008e37b6SJohn Marino
4264*6ea1f93eSDaniel Fojt'-Z'
4265*6ea1f93eSDaniel Fojt'--ignore-trailing-space'
4266008e37b6SJohn Marino     Ignore white space at line end.  *Note White Space::.
4267008e37b6SJohn Marino
4268008e37b6SJohn Marino
4269*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Standards conformance,  Next: Projects,  Prev: Invoking sdiff,  Up: Top
4270008e37b6SJohn Marino
4271008e37b6SJohn Marino17 Standards conformance
4272008e37b6SJohn Marino************************
4273008e37b6SJohn Marino
4274*6ea1f93eSDaniel FojtIn a few cases, the GNU utilities' default behavior is incompatible with
4275*6ea1f93eSDaniel Fojtthe POSIX standard.  To suppress these incompatibilities, define the
4276*6ea1f93eSDaniel Fojt'POSIXLY_CORRECT' environment variable.  Unless you are checking for
4277*6ea1f93eSDaniel FojtPOSIX conformance, you probably do not need to define 'POSIXLY_CORRECT'.
4278008e37b6SJohn Marino
4279008e37b6SJohn Marino   Normally options and operands can appear in any order, and programs
4280008e37b6SJohn Marinoact as if all the options appear before any operands.  For example,
4281*6ea1f93eSDaniel Fojt'diff lao tzu -C 2' acts like 'diff -C 2 lao tzu', since '2' is an
4282*6ea1f93eSDaniel Fojtoption-argument of '-C'.  However, if the 'POSIXLY_CORRECT' environment
4283008e37b6SJohn Marinovariable is set, options must appear before operands, unless otherwise
4284008e37b6SJohn Marinospecified for a particular command.
4285008e37b6SJohn Marino
4286008e37b6SJohn Marino   Newer versions of POSIX are occasionally incompatible with older
4287008e37b6SJohn Marinoversions.  For example, older versions of POSIX allowed the command
4288*6ea1f93eSDaniel Fojt'diff -c -10' to have the same meaning as 'diff -C 10', but POSIX
4289*6ea1f93eSDaniel Fojt1003.1-2001 'diff' no longer allows digit-string options like '-10'.
4290008e37b6SJohn Marino
4291008e37b6SJohn Marino   The GNU utilities normally conform to the version of POSIX that is
4292008e37b6SJohn Marinostandard for your system.  To cause them to conform to a different
4293*6ea1f93eSDaniel Fojtversion of POSIX, define the '_POSIX2_VERSION' environment variable to a
4294*6ea1f93eSDaniel Fojtvalue of the form YYYYMM specifying the year and month the standard was
4295*6ea1f93eSDaniel Fojtadopted.  Two values are currently supported for '_POSIX2_VERSION':
4296*6ea1f93eSDaniel Fojt'199209' stands for POSIX 1003.2-1992, and '200112' stands for POSIX
4297008e37b6SJohn Marino1003.1-2001.  For example, if you are running older software that
4298*6ea1f93eSDaniel Fojtassumes an older version of POSIX and uses 'diff -c -10', you can work
4299*6ea1f93eSDaniel Fojtaround the compatibility problems by setting '_POSIX2_VERSION=199209' in
4300*6ea1f93eSDaniel Fojtyour environment.
4301008e37b6SJohn Marino
4302008e37b6SJohn Marino
4303*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Projects,  Next: Copying This Manual,  Prev: Standards conformance,  Up: Top
4304008e37b6SJohn Marino
4305008e37b6SJohn Marino18 Future Projects
4306008e37b6SJohn Marino******************
4307008e37b6SJohn Marino
4308*6ea1f93eSDaniel FojtHere are some ideas for improving GNU 'diff' and 'patch'.  The GNU
4309008e37b6SJohn Marinoproject has identified some improvements as potential programming
4310008e37b6SJohn Marinoprojects for volunteers.  You can also help by reporting any bugs that
4311008e37b6SJohn Marinoyou find.
4312008e37b6SJohn Marino
4313008e37b6SJohn Marino   If you are a programmer and would like to contribute something to the
4314*6ea1f93eSDaniel FojtGNU project, please consider volunteering for one of these projects.  If
4315*6ea1f93eSDaniel Fojtyou are seriously contemplating work, please write to <gvc@gnu.org> to
4316*6ea1f93eSDaniel Fojtcoordinate with other volunteers.
4317008e37b6SJohn Marino
4318008e37b6SJohn Marino* Menu:
4319008e37b6SJohn Marino
4320008e37b6SJohn Marino* Shortcomings:: Suggested projects for improvements.
4321008e37b6SJohn Marino* Bugs::         Reporting bugs.
4322008e37b6SJohn Marino
4323008e37b6SJohn Marino
4324*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Shortcomings,  Next: Bugs,  Up: Projects
4325008e37b6SJohn Marino
4326*6ea1f93eSDaniel Fojt18.1 Suggested Projects for Improving GNU 'diff' and 'patch'
4327008e37b6SJohn Marino============================================================
4328008e37b6SJohn Marino
4329*6ea1f93eSDaniel FojtOne should be able to use GNU 'diff' to generate a patch from any pair
4330*6ea1f93eSDaniel Fojtof directory trees, and given the patch and a copy of one such tree, use
4331*6ea1f93eSDaniel Fojt'patch' to generate a faithful copy of the other.  Unfortunately, some
4332*6ea1f93eSDaniel Fojtchanges to directory trees cannot be expressed using current patch
4333*6ea1f93eSDaniel Fojtformats; also, 'patch' does not handle some of the existing formats.
4334008e37b6SJohn MarinoThese shortcomings motivate the following suggested projects.
4335008e37b6SJohn Marino
4336008e37b6SJohn Marino* Menu:
4337008e37b6SJohn Marino
4338008e37b6SJohn Marino* Internationalization:: Handling multibyte and varying-width characters.
4339008e37b6SJohn Marino* Changing Structure::   Handling changes to the directory structure.
4340008e37b6SJohn Marino* Special Files::        Handling symbolic links, device special files, etc.
4341008e37b6SJohn Marino* Unusual File Names::   Handling file names that contain unusual characters.
4342*6ea1f93eSDaniel Fojt* Timestamp Order::     Outputting diffs in timestamp order.
4343008e37b6SJohn Marino* Ignoring Changes::     Ignoring certain changes while showing others.
4344008e37b6SJohn Marino* Speedups::             Improving performance.
4345008e37b6SJohn Marino
4346008e37b6SJohn Marino
4347*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Internationalization,  Next: Changing Structure,  Up: Shortcomings
4348008e37b6SJohn Marino
4349008e37b6SJohn Marino18.1.1 Handling Multibyte and Varying-Width Characters
4350008e37b6SJohn Marino------------------------------------------------------
4351008e37b6SJohn Marino
4352*6ea1f93eSDaniel Fojt'diff', 'diff3' and 'sdiff' treat each line of input as a string of
4353008e37b6SJohn Marinounibyte characters.  This can mishandle multibyte characters in some
4354*6ea1f93eSDaniel Fojtcases.  For example, when asked to ignore spaces, 'diff' does not
4355008e37b6SJohn Marinoproperly ignore a multibyte space character.
4356008e37b6SJohn Marino
4357*6ea1f93eSDaniel Fojt   Also, 'diff' currently assumes that each byte is one column wide, and
4358*6ea1f93eSDaniel Fojtthis assumption is incorrect in some locales, e.g., locales that use
4359*6ea1f93eSDaniel FojtUTF-8 encoding.  This causes problems with the '-y' or '--side-by-side'
4360*6ea1f93eSDaniel Fojtoption of 'diff'.
4361008e37b6SJohn Marino
4362008e37b6SJohn Marino   These problems need to be fixed without unduly affecting the
4363008e37b6SJohn Marinoperformance of the utilities in unibyte environments.
4364008e37b6SJohn Marino
4365008e37b6SJohn Marino   The IBM GNU/Linux Technology Center Internationalization Team has
4366*6ea1f93eSDaniel Fojtproposed patches to support internationalized 'diff'
4367008e37b6SJohn Marino(http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz).
4368008e37b6SJohn MarinoUnfortunately, these patches are incomplete and are to an older version
4369*6ea1f93eSDaniel Fojtof 'diff', so more work needs to be done in this area.
4370008e37b6SJohn Marino
4371008e37b6SJohn Marino
4372*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Changing Structure,  Next: Special Files,  Prev: Internationalization,  Up: Shortcomings
4373008e37b6SJohn Marino
4374008e37b6SJohn Marino18.1.2 Handling Changes to the Directory Structure
4375008e37b6SJohn Marino--------------------------------------------------
4376008e37b6SJohn Marino
4377*6ea1f93eSDaniel Fojt'diff' and 'patch' do not handle some changes to directory structure.
4378*6ea1f93eSDaniel FojtFor example, suppose one directory tree contains a directory named 'D'
4379008e37b6SJohn Marinowith some subsidiary files, and another contains a file with the same
4380*6ea1f93eSDaniel Fojtname 'D'.  'diff -r' does not output enough information for 'patch' to
4381008e37b6SJohn Marinotransform the directory subtree into the file.
4382008e37b6SJohn Marino
4383008e37b6SJohn Marino   There should be a way to specify that a file has been removed without
4384008e37b6SJohn Marinohaving to include its entire contents in the patch file.  There should
4385*6ea1f93eSDaniel Fojtalso be a way to tell 'patch' that a file was renamed, even if there is
4386*6ea1f93eSDaniel Fojtno way for 'diff' to generate such information.  There should be a way
4387*6ea1f93eSDaniel Fojtto tell 'patch' that a file's timestamp has changed, even if its
4388008e37b6SJohn Marinocontents have not changed.
4389008e37b6SJohn Marino
4390*6ea1f93eSDaniel Fojt   These problems can be fixed by extending the 'diff' output format to
4391*6ea1f93eSDaniel Fojtrepresent changes in directory structure, and extending 'patch' to
4392008e37b6SJohn Marinounderstand these extensions.
4393008e37b6SJohn Marino
4394008e37b6SJohn Marino
4395*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Special Files,  Next: Unusual File Names,  Prev: Changing Structure,  Up: Shortcomings
4396008e37b6SJohn Marino
4397008e37b6SJohn Marino18.1.3 Files that are Neither Directories Nor Regular Files
4398008e37b6SJohn Marino-----------------------------------------------------------
4399008e37b6SJohn Marino
4400008e37b6SJohn MarinoSome files are neither directories nor regular files: they are unusual
4401008e37b6SJohn Marinofiles like symbolic links, device special files, named pipes, and
4402*6ea1f93eSDaniel Fojtsockets.  Currently, 'diff' treats symbolic links as if they were the
4403*6ea1f93eSDaniel Fojtpointed-to files, except that a recursive 'diff' reports an error if it
4404*6ea1f93eSDaniel Fojtdetects infinite loops of symbolic links (e.g., symbolic links to '..').
4405*6ea1f93eSDaniel Fojt'diff' treats other special files like regular files if they are
4406*6ea1f93eSDaniel Fojtspecified at the top level, but simply reports their presence when
4407*6ea1f93eSDaniel Fojtcomparing directories.  This means that 'patch' cannot represent changes
4408*6ea1f93eSDaniel Fojtto such files.  For example, if you change which file a symbolic link
4409*6ea1f93eSDaniel Fojtpoints to, 'diff' outputs the difference between the two files, instead
4410*6ea1f93eSDaniel Fojtof the change to the symbolic link.
4411008e37b6SJohn Marino
4412*6ea1f93eSDaniel Fojt   'diff' should optionally report changes to special files specially,
4413*6ea1f93eSDaniel Fojtand 'patch' should be extended to understand these extensions.
4414008e37b6SJohn Marino
4415008e37b6SJohn Marino
4416*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Unusual File Names,  Next: Timestamp Order,  Prev: Special Files,  Up: Shortcomings
4417008e37b6SJohn Marino
4418008e37b6SJohn Marino18.1.4 File Names that Contain Unusual Characters
4419008e37b6SJohn Marino-------------------------------------------------
4420008e37b6SJohn Marino
4421008e37b6SJohn MarinoWhen a file name contains an unusual character like a newline or white
4422*6ea1f93eSDaniel Fojtspace, 'diff -r' generates a patch that 'patch' cannot parse.  The
4423*6ea1f93eSDaniel Fojtproblem is with format of 'diff' output, not just with 'patch', because
4424*6ea1f93eSDaniel Fojtwith odd enough file names one can cause 'diff' to generate a patch that
4425*6ea1f93eSDaniel Fojtis syntactically correct but patches the wrong files.  The format of
4426*6ea1f93eSDaniel Fojt'diff' output should be extended to handle all possible file names.
4427008e37b6SJohn Marino
4428008e37b6SJohn Marino
4429*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Timestamp Order,  Next: Ignoring Changes,  Prev: Unusual File Names,  Up: Shortcomings
4430008e37b6SJohn Marino
4431*6ea1f93eSDaniel Fojt18.1.5 Outputting Diffs in Timestamp Order
4432*6ea1f93eSDaniel Fojt------------------------------------------
4433008e37b6SJohn Marino
4434*6ea1f93eSDaniel FojtApplying 'patch' to a multiple-file diff can result in files whose
4435*6ea1f93eSDaniel Fojttimestamps are out of order.  GNU 'patch' has options to restore the
4436*6ea1f93eSDaniel Fojttimestamps of the updated files (*note Patching Timestamps::), but
4437008e37b6SJohn Marinosometimes it is useful to generate a patch that works even if the
4438008e37b6SJohn Marinorecipient does not have GNU patch, or does not use these options.  One
4439*6ea1f93eSDaniel Fojtway to do this would be to implement a 'diff' option to output diffs in
4440008e37b6SJohn Marinotimestamp order.
4441008e37b6SJohn Marino
4442008e37b6SJohn Marino
4443*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Ignoring Changes,  Next: Speedups,  Prev: Timestamp Order,  Up: Shortcomings
4444008e37b6SJohn Marino
4445008e37b6SJohn Marino18.1.6 Ignoring Certain Changes
4446008e37b6SJohn Marino-------------------------------
4447008e37b6SJohn Marino
4448008e37b6SJohn MarinoIt would be nice to have a feature for specifying two strings, one in
4449008e37b6SJohn MarinoFROM-FILE and one in TO-FILE, which should be considered to match.
4450*6ea1f93eSDaniel FojtThus, if the two strings are 'foo' and 'bar', then if two lines differ
4451*6ea1f93eSDaniel Fojtonly in that 'foo' in file 1 corresponds to 'bar' in file 2, the lines
4452008e37b6SJohn Marinoare treated as identical.
4453008e37b6SJohn Marino
4454008e37b6SJohn Marino   It is not clear how general this feature can or should be, or what
4455008e37b6SJohn Marinosyntax should be used for it.
4456008e37b6SJohn Marino
4457008e37b6SJohn Marino   A partial substitute is to filter one or both files before comparing,
4458008e37b6SJohn Marinoe.g.:
4459008e37b6SJohn Marino
4460008e37b6SJohn Marino     sed 's/foo/bar/g' file1 | diff - file2
4461008e37b6SJohn Marino
4462008e37b6SJohn Marino   However, this outputs the filtered text, not the original.
4463008e37b6SJohn Marino
4464008e37b6SJohn Marino
4465*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Speedups,  Prev: Ignoring Changes,  Up: Shortcomings
4466008e37b6SJohn Marino
4467008e37b6SJohn Marino18.1.7 Improving Performance
4468008e37b6SJohn Marino----------------------------
4469008e37b6SJohn Marino
4470008e37b6SJohn MarinoWhen comparing two large directory structures, one of which was
4471008e37b6SJohn Marinooriginally copied from the other with timestamps preserved (e.g., with
4472*6ea1f93eSDaniel Fojt'cp -pR'), it would greatly improve performance if an option told 'diff'
4473*6ea1f93eSDaniel Fojtto assume that two files with the same size and timestamps have the same
4474*6ea1f93eSDaniel Fojtcontent.  *Note diff Performance::.
4475008e37b6SJohn Marino
4476008e37b6SJohn Marino
4477*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Bugs,  Prev: Shortcomings,  Up: Projects
4478008e37b6SJohn Marino
4479008e37b6SJohn Marino18.2 Reporting Bugs
4480008e37b6SJohn Marino===================
4481008e37b6SJohn Marino
4482*6ea1f93eSDaniel FojtIf you think you have found a bug in GNU 'cmp', 'diff', 'diff3', or
4483*6ea1f93eSDaniel Fojt'sdiff', please report it by electronic mail to the GNU utilities bug
4484*6ea1f93eSDaniel Fojtreport mailing list (http://mail.gnu.org/mailman/listinfo/bug-diffutils)
4485*6ea1f93eSDaniel Fojt<bug-diffutils@gnu.org>.  Please send bug reports for GNU 'patch' to
4486008e37b6SJohn Marino<bug-patch@gnu.org>.  Send as precise a description of the problem as
4487*6ea1f93eSDaniel Fojtyou can, including the output of the '--version' option and sample input
4488*6ea1f93eSDaniel Fojtfiles that produce the bug, if applicable.  If you have a nontrivial fix
4489*6ea1f93eSDaniel Fojtfor the bug, please send it as well.  If you have a patch, please send
4490*6ea1f93eSDaniel Fojtit too.  It may simplify the maintainer's job if the patch is relative
4491*6ea1f93eSDaniel Fojtto a recent test release, which you can find in the directory
4492*6ea1f93eSDaniel Fojt<ftp://alpha.gnu.org/gnu/diffutils/>.
4493008e37b6SJohn Marino
4494008e37b6SJohn Marino
4495*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Copying This Manual,  Next: Translations,  Prev: Projects,  Up: Top
4496008e37b6SJohn Marino
4497008e37b6SJohn MarinoAppendix A Copying This Manual
4498008e37b6SJohn Marino******************************
4499008e37b6SJohn Marino
4500008e37b6SJohn Marino                     Version 1.3, 3 November 2008
4501008e37b6SJohn Marino
4502008e37b6SJohn Marino     Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
4503*6ea1f93eSDaniel Fojt     <https://fsf.org/>
4504008e37b6SJohn Marino
4505008e37b6SJohn Marino     Everyone is permitted to copy and distribute verbatim copies
4506008e37b6SJohn Marino     of this license document, but changing it is not allowed.
4507008e37b6SJohn Marino
4508008e37b6SJohn Marino  0. PREAMBLE
4509008e37b6SJohn Marino
4510008e37b6SJohn Marino     The purpose of this License is to make a manual, textbook, or other
4511008e37b6SJohn Marino     functional and useful document "free" in the sense of freedom: to
4512008e37b6SJohn Marino     assure everyone the effective freedom to copy and redistribute it,
4513008e37b6SJohn Marino     with or without modifying it, either commercially or
4514008e37b6SJohn Marino     noncommercially.  Secondarily, this License preserves for the
4515008e37b6SJohn Marino     author and publisher a way to get credit for their work, while not
4516008e37b6SJohn Marino     being considered responsible for modifications made by others.
4517008e37b6SJohn Marino
4518008e37b6SJohn Marino     This License is a kind of "copyleft", which means that derivative
4519008e37b6SJohn Marino     works of the document must themselves be free in the same sense.
4520008e37b6SJohn Marino     It complements the GNU General Public License, which is a copyleft
4521008e37b6SJohn Marino     license designed for free software.
4522008e37b6SJohn Marino
4523008e37b6SJohn Marino     We have designed this License in order to use it for manuals for
4524008e37b6SJohn Marino     free software, because free software needs free documentation: a
4525008e37b6SJohn Marino     free program should come with manuals providing the same freedoms
4526008e37b6SJohn Marino     that the software does.  But this License is not limited to
4527008e37b6SJohn Marino     software manuals; it can be used for any textual work, regardless
4528*6ea1f93eSDaniel Fojt     of subject matter or whether it is published as a printed book.  We
4529*6ea1f93eSDaniel Fojt     recommend this License principally for works whose purpose is
4530008e37b6SJohn Marino     instruction or reference.
4531008e37b6SJohn Marino
4532008e37b6SJohn Marino  1. APPLICABILITY AND DEFINITIONS
4533008e37b6SJohn Marino
4534008e37b6SJohn Marino     This License applies to any manual or other work, in any medium,
4535*6ea1f93eSDaniel Fojt     that contains a notice placed by the copyright holder saying it can
4536*6ea1f93eSDaniel Fojt     be distributed under the terms of this License.  Such a notice
4537008e37b6SJohn Marino     grants a world-wide, royalty-free license, unlimited in duration,
4538008e37b6SJohn Marino     to use that work under the conditions stated herein.  The
4539008e37b6SJohn Marino     "Document", below, refers to any such manual or work.  Any member
4540*6ea1f93eSDaniel Fojt     of the public is a licensee, and is addressed as "you".  You accept
4541*6ea1f93eSDaniel Fojt     the license if you copy, modify or distribute the work in a way
4542*6ea1f93eSDaniel Fojt     requiring permission under copyright law.
4543008e37b6SJohn Marino
4544008e37b6SJohn Marino     A "Modified Version" of the Document means any work containing the
4545008e37b6SJohn Marino     Document or a portion of it, either copied verbatim, or with
4546008e37b6SJohn Marino     modifications and/or translated into another language.
4547008e37b6SJohn Marino
4548008e37b6SJohn Marino     A "Secondary Section" is a named appendix or a front-matter section
4549008e37b6SJohn Marino     of the Document that deals exclusively with the relationship of the
4550008e37b6SJohn Marino     publishers or authors of the Document to the Document's overall
4551008e37b6SJohn Marino     subject (or to related matters) and contains nothing that could
4552008e37b6SJohn Marino     fall directly within that overall subject.  (Thus, if the Document
4553008e37b6SJohn Marino     is in part a textbook of mathematics, a Secondary Section may not
4554008e37b6SJohn Marino     explain any mathematics.)  The relationship could be a matter of
4555008e37b6SJohn Marino     historical connection with the subject or with related matters, or
4556008e37b6SJohn Marino     of legal, commercial, philosophical, ethical or political position
4557008e37b6SJohn Marino     regarding them.
4558008e37b6SJohn Marino
4559008e37b6SJohn Marino     The "Invariant Sections" are certain Secondary Sections whose
4560*6ea1f93eSDaniel Fojt     titles are designated, as being those of Invariant Sections, in the
4561*6ea1f93eSDaniel Fojt     notice that says that the Document is released under this License.
4562*6ea1f93eSDaniel Fojt     If a section does not fit the above definition of Secondary then it
4563*6ea1f93eSDaniel Fojt     is not allowed to be designated as Invariant.  The Document may
4564*6ea1f93eSDaniel Fojt     contain zero Invariant Sections.  If the Document does not identify
4565*6ea1f93eSDaniel Fojt     any Invariant Sections then there are none.
4566008e37b6SJohn Marino
4567008e37b6SJohn Marino     The "Cover Texts" are certain short passages of text that are
4568008e37b6SJohn Marino     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4569008e37b6SJohn Marino     that says that the Document is released under this License.  A
4570008e37b6SJohn Marino     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4571008e37b6SJohn Marino     be at most 25 words.
4572008e37b6SJohn Marino
4573008e37b6SJohn Marino     A "Transparent" copy of the Document means a machine-readable copy,
4574008e37b6SJohn Marino     represented in a format whose specification is available to the
4575008e37b6SJohn Marino     general public, that is suitable for revising the document
4576*6ea1f93eSDaniel Fojt     straightforwardly with generic text editors or (for images composed
4577*6ea1f93eSDaniel Fojt     of pixels) generic paint programs or (for drawings) some widely
4578*6ea1f93eSDaniel Fojt     available drawing editor, and that is suitable for input to text
4579*6ea1f93eSDaniel Fojt     formatters or for automatic translation to a variety of formats
4580*6ea1f93eSDaniel Fojt     suitable for input to text formatters.  A copy made in an otherwise
4581*6ea1f93eSDaniel Fojt     Transparent file format whose markup, or absence of markup, has
4582*6ea1f93eSDaniel Fojt     been arranged to thwart or discourage subsequent modification by
4583*6ea1f93eSDaniel Fojt     readers is not Transparent.  An image format is not Transparent if
4584*6ea1f93eSDaniel Fojt     used for any substantial amount of text.  A copy that is not
4585*6ea1f93eSDaniel Fojt     "Transparent" is called "Opaque".
4586008e37b6SJohn Marino
4587008e37b6SJohn Marino     Examples of suitable formats for Transparent copies include plain
4588008e37b6SJohn Marino     ASCII without markup, Texinfo input format, LaTeX input format,
4589*6ea1f93eSDaniel Fojt     SGML or XML using a publicly available DTD, and standard-conforming
4590*6ea1f93eSDaniel Fojt     simple HTML, PostScript or PDF designed for human modification.
4591*6ea1f93eSDaniel Fojt     Examples of transparent image formats include PNG, XCF and JPG.
4592*6ea1f93eSDaniel Fojt     Opaque formats include proprietary formats that can be read and
4593*6ea1f93eSDaniel Fojt     edited only by proprietary word processors, SGML or XML for which
4594*6ea1f93eSDaniel Fojt     the DTD and/or processing tools are not generally available, and
4595*6ea1f93eSDaniel Fojt     the machine-generated HTML, PostScript or PDF produced by some word
4596*6ea1f93eSDaniel Fojt     processors for output purposes only.
4597008e37b6SJohn Marino
4598008e37b6SJohn Marino     The "Title Page" means, for a printed book, the title page itself,
4599008e37b6SJohn Marino     plus such following pages as are needed to hold, legibly, the
4600008e37b6SJohn Marino     material this License requires to appear in the title page.  For
4601008e37b6SJohn Marino     works in formats which do not have any title page as such, "Title
4602008e37b6SJohn Marino     Page" means the text near the most prominent appearance of the
4603008e37b6SJohn Marino     work's title, preceding the beginning of the body of the text.
4604008e37b6SJohn Marino
4605008e37b6SJohn Marino     The "publisher" means any person or entity that distributes copies
4606008e37b6SJohn Marino     of the Document to the public.
4607008e37b6SJohn Marino
4608008e37b6SJohn Marino     A section "Entitled XYZ" means a named subunit of the Document
4609008e37b6SJohn Marino     whose title either is precisely XYZ or contains XYZ in parentheses
4610008e37b6SJohn Marino     following text that translates XYZ in another language.  (Here XYZ
4611008e37b6SJohn Marino     stands for a specific section name mentioned below, such as
4612008e37b6SJohn Marino     "Acknowledgements", "Dedications", "Endorsements", or "History".)
4613008e37b6SJohn Marino     To "Preserve the Title" of such a section when you modify the
4614008e37b6SJohn Marino     Document means that it remains a section "Entitled XYZ" according
4615008e37b6SJohn Marino     to this definition.
4616008e37b6SJohn Marino
4617008e37b6SJohn Marino     The Document may include Warranty Disclaimers next to the notice
4618008e37b6SJohn Marino     which states that this License applies to the Document.  These
4619008e37b6SJohn Marino     Warranty Disclaimers are considered to be included by reference in
4620008e37b6SJohn Marino     this License, but only as regards disclaiming warranties: any other
4621008e37b6SJohn Marino     implication that these Warranty Disclaimers may have is void and
4622008e37b6SJohn Marino     has no effect on the meaning of this License.
4623008e37b6SJohn Marino
4624008e37b6SJohn Marino  2. VERBATIM COPYING
4625008e37b6SJohn Marino
4626008e37b6SJohn Marino     You may copy and distribute the Document in any medium, either
4627008e37b6SJohn Marino     commercially or noncommercially, provided that this License, the
4628008e37b6SJohn Marino     copyright notices, and the license notice saying this License
4629008e37b6SJohn Marino     applies to the Document are reproduced in all copies, and that you
4630008e37b6SJohn Marino     add no other conditions whatsoever to those of this License.  You
4631008e37b6SJohn Marino     may not use technical measures to obstruct or control the reading
4632008e37b6SJohn Marino     or further copying of the copies you make or distribute.  However,
4633008e37b6SJohn Marino     you may accept compensation in exchange for copies.  If you
4634*6ea1f93eSDaniel Fojt     distribute a large enough number of copies you must also follow the
4635*6ea1f93eSDaniel Fojt     conditions in section 3.
4636008e37b6SJohn Marino
4637008e37b6SJohn Marino     You may also lend copies, under the same conditions stated above,
4638008e37b6SJohn Marino     and you may publicly display copies.
4639008e37b6SJohn Marino
4640008e37b6SJohn Marino  3. COPYING IN QUANTITY
4641008e37b6SJohn Marino
4642008e37b6SJohn Marino     If you publish printed copies (or copies in media that commonly
4643008e37b6SJohn Marino     have printed covers) of the Document, numbering more than 100, and
4644008e37b6SJohn Marino     the Document's license notice requires Cover Texts, you must
4645008e37b6SJohn Marino     enclose the copies in covers that carry, clearly and legibly, all
4646008e37b6SJohn Marino     these Cover Texts: Front-Cover Texts on the front cover, and
4647008e37b6SJohn Marino     Back-Cover Texts on the back cover.  Both covers must also clearly
4648008e37b6SJohn Marino     and legibly identify you as the publisher of these copies.  The
4649*6ea1f93eSDaniel Fojt     front cover must present the full title with all words of the title
4650*6ea1f93eSDaniel Fojt     equally prominent and visible.  You may add other material on the
4651*6ea1f93eSDaniel Fojt     covers in addition.  Copying with changes limited to the covers, as
4652*6ea1f93eSDaniel Fojt     long as they preserve the title of the Document and satisfy these
4653*6ea1f93eSDaniel Fojt     conditions, can be treated as verbatim copying in other respects.
4654008e37b6SJohn Marino
4655008e37b6SJohn Marino     If the required texts for either cover are too voluminous to fit
4656008e37b6SJohn Marino     legibly, you should put the first ones listed (as many as fit
4657008e37b6SJohn Marino     reasonably) on the actual cover, and continue the rest onto
4658008e37b6SJohn Marino     adjacent pages.
4659008e37b6SJohn Marino
4660008e37b6SJohn Marino     If you publish or distribute Opaque copies of the Document
4661*6ea1f93eSDaniel Fojt     numbering more than 100, you must either include a machine-readable
4662*6ea1f93eSDaniel Fojt     Transparent copy along with each Opaque copy, or state in or with
4663*6ea1f93eSDaniel Fojt     each Opaque copy a computer-network location from which the general
4664*6ea1f93eSDaniel Fojt     network-using public has access to download using public-standard
4665*6ea1f93eSDaniel Fojt     network protocols a complete Transparent copy of the Document, free
4666*6ea1f93eSDaniel Fojt     of added material.  If you use the latter option, you must take
4667*6ea1f93eSDaniel Fojt     reasonably prudent steps, when you begin distribution of Opaque
4668*6ea1f93eSDaniel Fojt     copies in quantity, to ensure that this Transparent copy will
4669*6ea1f93eSDaniel Fojt     remain thus accessible at the stated location until at least one
4670*6ea1f93eSDaniel Fojt     year after the last time you distribute an Opaque copy (directly or
4671*6ea1f93eSDaniel Fojt     through your agents or retailers) of that edition to the public.
4672008e37b6SJohn Marino
4673008e37b6SJohn Marino     It is requested, but not required, that you contact the authors of
4674*6ea1f93eSDaniel Fojt     the Document well before redistributing any large number of copies,
4675*6ea1f93eSDaniel Fojt     to give them a chance to provide you with an updated version of the
4676*6ea1f93eSDaniel Fojt     Document.
4677008e37b6SJohn Marino
4678008e37b6SJohn Marino  4. MODIFICATIONS
4679008e37b6SJohn Marino
4680008e37b6SJohn Marino     You may copy and distribute a Modified Version of the Document
4681008e37b6SJohn Marino     under the conditions of sections 2 and 3 above, provided that you
4682*6ea1f93eSDaniel Fojt     release the Modified Version under precisely this License, with the
4683*6ea1f93eSDaniel Fojt     Modified Version filling the role of the Document, thus licensing
4684*6ea1f93eSDaniel Fojt     distribution and modification of the Modified Version to whoever
4685*6ea1f93eSDaniel Fojt     possesses a copy of it.  In addition, you must do these things in
4686*6ea1f93eSDaniel Fojt     the Modified Version:
4687008e37b6SJohn Marino
4688008e37b6SJohn Marino       A. Use in the Title Page (and on the covers, if any) a title
4689*6ea1f93eSDaniel Fojt          distinct from that of the Document, and from those of previous
4690*6ea1f93eSDaniel Fojt          versions (which should, if there were any, be listed in the
4691*6ea1f93eSDaniel Fojt          History section of the Document).  You may use the same title
4692*6ea1f93eSDaniel Fojt          as a previous version if the original publisher of that
4693*6ea1f93eSDaniel Fojt          version gives permission.
4694008e37b6SJohn Marino
4695008e37b6SJohn Marino       B. List on the Title Page, as authors, one or more persons or
4696008e37b6SJohn Marino          entities responsible for authorship of the modifications in
4697008e37b6SJohn Marino          the Modified Version, together with at least five of the
4698008e37b6SJohn Marino          principal authors of the Document (all of its principal
4699008e37b6SJohn Marino          authors, if it has fewer than five), unless they release you
4700008e37b6SJohn Marino          from this requirement.
4701008e37b6SJohn Marino
4702008e37b6SJohn Marino       C. State on the Title page the name of the publisher of the
4703008e37b6SJohn Marino          Modified Version, as the publisher.
4704008e37b6SJohn Marino
4705008e37b6SJohn Marino       D. Preserve all the copyright notices of the Document.
4706008e37b6SJohn Marino
4707008e37b6SJohn Marino       E. Add an appropriate copyright notice for your modifications
4708008e37b6SJohn Marino          adjacent to the other copyright notices.
4709008e37b6SJohn Marino
4710008e37b6SJohn Marino       F. Include, immediately after the copyright notices, a license
4711008e37b6SJohn Marino          notice giving the public permission to use the Modified
4712008e37b6SJohn Marino          Version under the terms of this License, in the form shown in
4713008e37b6SJohn Marino          the Addendum below.
4714008e37b6SJohn Marino
4715008e37b6SJohn Marino       G. Preserve in that license notice the full lists of Invariant
4716008e37b6SJohn Marino          Sections and required Cover Texts given in the Document's
4717008e37b6SJohn Marino          license notice.
4718008e37b6SJohn Marino
4719008e37b6SJohn Marino       H. Include an unaltered copy of this License.
4720008e37b6SJohn Marino
4721008e37b6SJohn Marino       I. Preserve the section Entitled "History", Preserve its Title,
4722008e37b6SJohn Marino          and add to it an item stating at least the title, year, new
4723*6ea1f93eSDaniel Fojt          authors, and publisher of the Modified Version as given on the
4724*6ea1f93eSDaniel Fojt          Title Page.  If there is no section Entitled "History" in the
4725*6ea1f93eSDaniel Fojt          Document, create one stating the title, year, authors, and
4726*6ea1f93eSDaniel Fojt          publisher of the Document as given on its Title Page, then add
4727*6ea1f93eSDaniel Fojt          an item describing the Modified Version as stated in the
4728*6ea1f93eSDaniel Fojt          previous sentence.
4729008e37b6SJohn Marino
4730008e37b6SJohn Marino       J. Preserve the network location, if any, given in the Document
4731008e37b6SJohn Marino          for public access to a Transparent copy of the Document, and
4732008e37b6SJohn Marino          likewise the network locations given in the Document for
4733*6ea1f93eSDaniel Fojt          previous versions it was based on.  These may be placed in the
4734*6ea1f93eSDaniel Fojt          "History" section.  You may omit a network location for a work
4735*6ea1f93eSDaniel Fojt          that was published at least four years before the Document
4736*6ea1f93eSDaniel Fojt          itself, or if the original publisher of the version it refers
4737*6ea1f93eSDaniel Fojt          to gives permission.
4738008e37b6SJohn Marino
4739008e37b6SJohn Marino       K. For any section Entitled "Acknowledgements" or "Dedications",
4740*6ea1f93eSDaniel Fojt          Preserve the Title of the section, and preserve in the section
4741*6ea1f93eSDaniel Fojt          all the substance and tone of each of the contributor
4742008e37b6SJohn Marino          acknowledgements and/or dedications given therein.
4743008e37b6SJohn Marino
4744*6ea1f93eSDaniel Fojt       L. Preserve all the Invariant Sections of the Document, unaltered
4745*6ea1f93eSDaniel Fojt          in their text and in their titles.  Section numbers or the
4746*6ea1f93eSDaniel Fojt          equivalent are not considered part of the section titles.
4747008e37b6SJohn Marino
4748008e37b6SJohn Marino       M. Delete any section Entitled "Endorsements".  Such a section
4749008e37b6SJohn Marino          may not be included in the Modified Version.
4750008e37b6SJohn Marino
4751008e37b6SJohn Marino       N. Do not retitle any existing section to be Entitled
4752008e37b6SJohn Marino          "Endorsements" or to conflict in title with any Invariant
4753008e37b6SJohn Marino          Section.
4754008e37b6SJohn Marino
4755008e37b6SJohn Marino       O. Preserve any Warranty Disclaimers.
4756008e37b6SJohn Marino
4757008e37b6SJohn Marino     If the Modified Version includes new front-matter sections or
4758008e37b6SJohn Marino     appendices that qualify as Secondary Sections and contain no
4759*6ea1f93eSDaniel Fojt     material copied from the Document, you may at your option designate
4760*6ea1f93eSDaniel Fojt     some or all of these sections as invariant.  To do this, add their
4761*6ea1f93eSDaniel Fojt     titles to the list of Invariant Sections in the Modified Version's
4762*6ea1f93eSDaniel Fojt     license notice.  These titles must be distinct from any other
4763*6ea1f93eSDaniel Fojt     section titles.
4764008e37b6SJohn Marino
4765008e37b6SJohn Marino     You may add a section Entitled "Endorsements", provided it contains
4766008e37b6SJohn Marino     nothing but endorsements of your Modified Version by various
4767008e37b6SJohn Marino     parties--for example, statements of peer review or that the text
4768008e37b6SJohn Marino     has been approved by an organization as the authoritative
4769008e37b6SJohn Marino     definition of a standard.
4770008e37b6SJohn Marino
4771008e37b6SJohn Marino     You may add a passage of up to five words as a Front-Cover Text,
4772*6ea1f93eSDaniel Fojt     and a passage of up to 25 words as a Back-Cover Text, to the end of
4773*6ea1f93eSDaniel Fojt     the list of Cover Texts in the Modified Version.  Only one passage
4774*6ea1f93eSDaniel Fojt     of Front-Cover Text and one of Back-Cover Text may be added by (or
4775*6ea1f93eSDaniel Fojt     through arrangements made by) any one entity.  If the Document
4776*6ea1f93eSDaniel Fojt     already includes a cover text for the same cover, previously added
4777*6ea1f93eSDaniel Fojt     by you or by arrangement made by the same entity you are acting on
4778*6ea1f93eSDaniel Fojt     behalf of, you may not add another; but you may replace the old
4779*6ea1f93eSDaniel Fojt     one, on explicit permission from the previous publisher that added
4780*6ea1f93eSDaniel Fojt     the old one.
4781008e37b6SJohn Marino
4782008e37b6SJohn Marino     The author(s) and publisher(s) of the Document do not by this
4783008e37b6SJohn Marino     License give permission to use their names for publicity for or to
4784008e37b6SJohn Marino     assert or imply endorsement of any Modified Version.
4785008e37b6SJohn Marino
4786008e37b6SJohn Marino  5. COMBINING DOCUMENTS
4787008e37b6SJohn Marino
4788008e37b6SJohn Marino     You may combine the Document with other documents released under
4789008e37b6SJohn Marino     this License, under the terms defined in section 4 above for
4790*6ea1f93eSDaniel Fojt     modified versions, provided that you include in the combination all
4791*6ea1f93eSDaniel Fojt     of the Invariant Sections of all of the original documents,
4792008e37b6SJohn Marino     unmodified, and list them all as Invariant Sections of your
4793008e37b6SJohn Marino     combined work in its license notice, and that you preserve all
4794008e37b6SJohn Marino     their Warranty Disclaimers.
4795008e37b6SJohn Marino
4796008e37b6SJohn Marino     The combined work need only contain one copy of this License, and
4797008e37b6SJohn Marino     multiple identical Invariant Sections may be replaced with a single
4798008e37b6SJohn Marino     copy.  If there are multiple Invariant Sections with the same name
4799008e37b6SJohn Marino     but different contents, make the title of each such section unique
4800008e37b6SJohn Marino     by adding at the end of it, in parentheses, the name of the
4801008e37b6SJohn Marino     original author or publisher of that section if known, or else a
4802008e37b6SJohn Marino     unique number.  Make the same adjustment to the section titles in
4803008e37b6SJohn Marino     the list of Invariant Sections in the license notice of the
4804008e37b6SJohn Marino     combined work.
4805008e37b6SJohn Marino
4806008e37b6SJohn Marino     In the combination, you must combine any sections Entitled
4807008e37b6SJohn Marino     "History" in the various original documents, forming one section
4808008e37b6SJohn Marino     Entitled "History"; likewise combine any sections Entitled
4809008e37b6SJohn Marino     "Acknowledgements", and any sections Entitled "Dedications".  You
4810008e37b6SJohn Marino     must delete all sections Entitled "Endorsements."
4811008e37b6SJohn Marino
4812008e37b6SJohn Marino  6. COLLECTIONS OF DOCUMENTS
4813008e37b6SJohn Marino
4814008e37b6SJohn Marino     You may make a collection consisting of the Document and other
4815008e37b6SJohn Marino     documents released under this License, and replace the individual
4816008e37b6SJohn Marino     copies of this License in the various documents with a single copy
4817008e37b6SJohn Marino     that is included in the collection, provided that you follow the
4818*6ea1f93eSDaniel Fojt     rules of this License for verbatim copying of each of the documents
4819*6ea1f93eSDaniel Fojt     in all other respects.
4820008e37b6SJohn Marino
4821008e37b6SJohn Marino     You may extract a single document from such a collection, and
4822008e37b6SJohn Marino     distribute it individually under this License, provided you insert
4823*6ea1f93eSDaniel Fojt     a copy of this License into the extracted document, and follow this
4824*6ea1f93eSDaniel Fojt     License in all other respects regarding verbatim copying of that
4825*6ea1f93eSDaniel Fojt     document.
4826008e37b6SJohn Marino
4827008e37b6SJohn Marino  7. AGGREGATION WITH INDEPENDENT WORKS
4828008e37b6SJohn Marino
4829008e37b6SJohn Marino     A compilation of the Document or its derivatives with other
4830*6ea1f93eSDaniel Fojt     separate and independent documents or works, in or on a volume of a
4831*6ea1f93eSDaniel Fojt     storage or distribution medium, is called an "aggregate" if the
4832008e37b6SJohn Marino     copyright resulting from the compilation is not used to limit the
4833008e37b6SJohn Marino     legal rights of the compilation's users beyond what the individual
4834008e37b6SJohn Marino     works permit.  When the Document is included in an aggregate, this
4835008e37b6SJohn Marino     License does not apply to the other works in the aggregate which
4836008e37b6SJohn Marino     are not themselves derivative works of the Document.
4837008e37b6SJohn Marino
4838008e37b6SJohn Marino     If the Cover Text requirement of section 3 is applicable to these
4839008e37b6SJohn Marino     copies of the Document, then if the Document is less than one half
4840008e37b6SJohn Marino     of the entire aggregate, the Document's Cover Texts may be placed
4841008e37b6SJohn Marino     on covers that bracket the Document within the aggregate, or the
4842008e37b6SJohn Marino     electronic equivalent of covers if the Document is in electronic
4843008e37b6SJohn Marino     form.  Otherwise they must appear on printed covers that bracket
4844008e37b6SJohn Marino     the whole aggregate.
4845008e37b6SJohn Marino
4846008e37b6SJohn Marino  8. TRANSLATION
4847008e37b6SJohn Marino
4848008e37b6SJohn Marino     Translation is considered a kind of modification, so you may
4849008e37b6SJohn Marino     distribute translations of the Document under the terms of section
4850008e37b6SJohn Marino     4.  Replacing Invariant Sections with translations requires special
4851008e37b6SJohn Marino     permission from their copyright holders, but you may include
4852008e37b6SJohn Marino     translations of some or all Invariant Sections in addition to the
4853008e37b6SJohn Marino     original versions of these Invariant Sections.  You may include a
4854008e37b6SJohn Marino     translation of this License, and all the license notices in the
4855008e37b6SJohn Marino     Document, and any Warranty Disclaimers, provided that you also
4856008e37b6SJohn Marino     include the original English version of this License and the
4857008e37b6SJohn Marino     original versions of those notices and disclaimers.  In case of a
4858008e37b6SJohn Marino     disagreement between the translation and the original version of
4859008e37b6SJohn Marino     this License or a notice or disclaimer, the original version will
4860008e37b6SJohn Marino     prevail.
4861008e37b6SJohn Marino
4862008e37b6SJohn Marino     If a section in the Document is Entitled "Acknowledgements",
4863008e37b6SJohn Marino     "Dedications", or "History", the requirement (section 4) to
4864008e37b6SJohn Marino     Preserve its Title (section 1) will typically require changing the
4865008e37b6SJohn Marino     actual title.
4866008e37b6SJohn Marino
4867008e37b6SJohn Marino  9. TERMINATION
4868008e37b6SJohn Marino
4869008e37b6SJohn Marino     You may not copy, modify, sublicense, or distribute the Document
4870008e37b6SJohn Marino     except as expressly provided under this License.  Any attempt
4871008e37b6SJohn Marino     otherwise to copy, modify, sublicense, or distribute it is void,
4872008e37b6SJohn Marino     and will automatically terminate your rights under this License.
4873008e37b6SJohn Marino
4874008e37b6SJohn Marino     However, if you cease all violation of this License, then your
4875008e37b6SJohn Marino     license from a particular copyright holder is reinstated (a)
4876*6ea1f93eSDaniel Fojt     provisionally, unless and until the copyright holder explicitly and
4877*6ea1f93eSDaniel Fojt     finally terminates your license, and (b) permanently, if the
4878008e37b6SJohn Marino     copyright holder fails to notify you of the violation by some
4879008e37b6SJohn Marino     reasonable means prior to 60 days after the cessation.
4880008e37b6SJohn Marino
4881008e37b6SJohn Marino     Moreover, your license from a particular copyright holder is
4882008e37b6SJohn Marino     reinstated permanently if the copyright holder notifies you of the
4883008e37b6SJohn Marino     violation by some reasonable means, this is the first time you have
4884008e37b6SJohn Marino     received notice of violation of this License (for any work) from
4885008e37b6SJohn Marino     that copyright holder, and you cure the violation prior to 30 days
4886008e37b6SJohn Marino     after your receipt of the notice.
4887008e37b6SJohn Marino
4888008e37b6SJohn Marino     Termination of your rights under this section does not terminate
4889*6ea1f93eSDaniel Fojt     the licenses of parties who have received copies or rights from you
4890*6ea1f93eSDaniel Fojt     under this License.  If your rights have been terminated and not
4891*6ea1f93eSDaniel Fojt     permanently reinstated, receipt of a copy of some or all of the
4892*6ea1f93eSDaniel Fojt     same material does not give you any rights to use it.
4893008e37b6SJohn Marino
4894008e37b6SJohn Marino  10. FUTURE REVISIONS OF THIS LICENSE
4895008e37b6SJohn Marino
4896008e37b6SJohn Marino     The Free Software Foundation may publish new, revised versions of
4897008e37b6SJohn Marino     the GNU Free Documentation License from time to time.  Such new
4898008e37b6SJohn Marino     versions will be similar in spirit to the present version, but may
4899008e37b6SJohn Marino     differ in detail to address new problems or concerns.  See
4900*6ea1f93eSDaniel Fojt     <https://www.gnu.org/copyleft/>.
4901008e37b6SJohn Marino
4902008e37b6SJohn Marino     Each version of the License is given a distinguishing version
4903008e37b6SJohn Marino     number.  If the Document specifies that a particular numbered
4904008e37b6SJohn Marino     version of this License "or any later version" applies to it, you
4905008e37b6SJohn Marino     have the option of following the terms and conditions either of
4906008e37b6SJohn Marino     that specified version or of any later version that has been
4907*6ea1f93eSDaniel Fojt     published (not as a draft) by the Free Software Foundation.  If the
4908*6ea1f93eSDaniel Fojt     Document does not specify a version number of this License, you may
4909*6ea1f93eSDaniel Fojt     choose any version ever published (not as a draft) by the Free
4910*6ea1f93eSDaniel Fojt     Software Foundation.  If the Document specifies that a proxy can
4911*6ea1f93eSDaniel Fojt     decide which future versions of this License can be used, that
4912008e37b6SJohn Marino     proxy's public statement of acceptance of a version permanently
4913008e37b6SJohn Marino     authorizes you to choose that version for the Document.
4914008e37b6SJohn Marino
4915008e37b6SJohn Marino  11. RELICENSING
4916008e37b6SJohn Marino
4917008e37b6SJohn Marino     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
4918008e37b6SJohn Marino     World Wide Web server that publishes copyrightable works and also
4919008e37b6SJohn Marino     provides prominent facilities for anybody to edit those works.  A
4920008e37b6SJohn Marino     public wiki that anybody can edit is an example of such a server.
4921008e37b6SJohn Marino     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
4922008e37b6SJohn Marino     site means any set of copyrightable works thus published on the MMC
4923008e37b6SJohn Marino     site.
4924008e37b6SJohn Marino
4925008e37b6SJohn Marino     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
4926008e37b6SJohn Marino     license published by Creative Commons Corporation, a not-for-profit
4927008e37b6SJohn Marino     corporation with a principal place of business in San Francisco,
4928008e37b6SJohn Marino     California, as well as future copyleft versions of that license
4929008e37b6SJohn Marino     published by that same organization.
4930008e37b6SJohn Marino
4931008e37b6SJohn Marino     "Incorporate" means to publish or republish a Document, in whole or
4932008e37b6SJohn Marino     in part, as part of another Document.
4933008e37b6SJohn Marino
4934008e37b6SJohn Marino     An MMC is "eligible for relicensing" if it is licensed under this
4935008e37b6SJohn Marino     License, and if all works that were first published under this
4936008e37b6SJohn Marino     License somewhere other than this MMC, and subsequently
4937008e37b6SJohn Marino     incorporated in whole or in part into the MMC, (1) had no cover
4938008e37b6SJohn Marino     texts or invariant sections, and (2) were thus incorporated prior
4939008e37b6SJohn Marino     to November 1, 2008.
4940008e37b6SJohn Marino
4941008e37b6SJohn Marino     The operator of an MMC Site may republish an MMC contained in the
4942008e37b6SJohn Marino     site under CC-BY-SA on the same site at any time before August 1,
4943008e37b6SJohn Marino     2009, provided the MMC is eligible for relicensing.
4944008e37b6SJohn Marino
4945008e37b6SJohn MarinoADDENDUM: How to use this License for your documents
4946008e37b6SJohn Marino====================================================
4947008e37b6SJohn Marino
4948008e37b6SJohn MarinoTo use this License in a document you have written, include a copy of
4949008e37b6SJohn Marinothe License in the document and put the following copyright and license
4950008e37b6SJohn Marinonotices just after the title page:
4951008e37b6SJohn Marino
4952008e37b6SJohn Marino       Copyright (C)  YEAR  YOUR NAME.
4953008e37b6SJohn Marino       Permission is granted to copy, distribute and/or modify this document
4954008e37b6SJohn Marino       under the terms of the GNU Free Documentation License, Version 1.3
4955008e37b6SJohn Marino       or any later version published by the Free Software Foundation;
4956008e37b6SJohn Marino       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
4957008e37b6SJohn Marino       Texts.  A copy of the license is included in the section entitled ``GNU
4958008e37b6SJohn Marino       Free Documentation License''.
4959008e37b6SJohn Marino
4960008e37b6SJohn Marino   If you have Invariant Sections, Front-Cover Texts and Back-Cover
4961008e37b6SJohn MarinoTexts, replace the "with...Texts." line with this:
4962008e37b6SJohn Marino
4963008e37b6SJohn Marino         with the Invariant Sections being LIST THEIR TITLES, with
4964008e37b6SJohn Marino         the Front-Cover Texts being LIST, and with the Back-Cover Texts
4965008e37b6SJohn Marino         being LIST.
4966008e37b6SJohn Marino
4967008e37b6SJohn Marino   If you have Invariant Sections without Cover Texts, or some other
4968008e37b6SJohn Marinocombination of the three, merge those two alternatives to suit the
4969008e37b6SJohn Marinosituation.
4970008e37b6SJohn Marino
4971008e37b6SJohn Marino   If your document contains nontrivial examples of program code, we
4972*6ea1f93eSDaniel Fojtrecommend releasing these examples in parallel under your choice of free
4973*6ea1f93eSDaniel Fojtsoftware license, such as the GNU General Public License, to permit
4974*6ea1f93eSDaniel Fojttheir use in free software.
4975008e37b6SJohn Marino
4976008e37b6SJohn Marino
4977*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Translations,  Next: Index,  Prev: Copying This Manual,  Up: Top
4978008e37b6SJohn Marino
4979008e37b6SJohn MarinoAppendix B Translations of This Manual
4980008e37b6SJohn Marino**************************************
4981008e37b6SJohn Marino
4982008e37b6SJohn MarinoNishio Futoshi of the GNUjdoc project has prepared a Japanese
4983008e37b6SJohn Marinotranslation of this manual.  Its most recent version can be found at
4984*6ea1f93eSDaniel Fojt<http://openlab.ring.gr.jp/gnujdoc/cvsweb/cvsweb.cgi/gnujdoc/>.
4985008e37b6SJohn Marino
4986008e37b6SJohn Marino
4987*6ea1f93eSDaniel FojtFile: diffutils.info,  Node: Index,  Prev: Translations,  Up: Top
4988008e37b6SJohn Marino
4989008e37b6SJohn MarinoAppendix C Index
4990008e37b6SJohn Marino****************
4991008e37b6SJohn Marino
4992008e37b6SJohn Marino�[index�]
4993008e37b6SJohn Marino* Menu:
4994008e37b6SJohn Marino
4995008e37b6SJohn Marino* ! output format:                       Context.             (line   6)
4996008e37b6SJohn Marino* +- output format:                      Unified Format.      (line   6)
4997008e37b6SJohn Marino* < output format:                       Normal.              (line   6)
4998008e37b6SJohn Marino* <<<<<<< for marking conflicts:         Marking Conflicts.   (line   6)
4999008e37b6SJohn Marino* _POSIX2_VERSION:                       Standards conformance.
5000*6ea1f93eSDaniel Fojt                                                              (line  23)
5001*6ea1f93eSDaniel Fojt* ad capability:                         diff Options.        (line 179)
5002008e37b6SJohn Marino* aligning tab stops:                    Tabs.                (line   6)
5003008e37b6SJohn Marino* alternate file names:                  Alternate Names.     (line   6)
5004*6ea1f93eSDaniel Fojt* always color option:                   diff Options.        (line  43)
5005*6ea1f93eSDaniel Fojt* auto color option:                     diff Options.        (line  42)
5006008e37b6SJohn Marino* backup file names:                     Backup Names.        (line   6)
5007008e37b6SJohn Marino* backup file strategy:                  Backups.             (line   6)
5008008e37b6SJohn Marino* binary file diff:                      Binary.              (line   6)
5009008e37b6SJohn Marino* blank and tab difference suppression:  White Space.         (line   6)
5010008e37b6SJohn Marino* blank line difference suppression:     Blank Lines.         (line   6)
5011008e37b6SJohn Marino* brief difference reports:              Brief.               (line   6)
5012008e37b6SJohn Marino* bug reports:                           Bugs.                (line   6)
5013008e37b6SJohn Marino* C function headings:                   C Function Headings. (line   6)
5014008e37b6SJohn Marino* C if-then-else output format:          If-then-else.        (line   6)
5015008e37b6SJohn Marino* case difference suppression:           Case Folding.        (line   6)
5016008e37b6SJohn Marino* ClearCase:                             Revision Control.    (line   6)
5017008e37b6SJohn Marino* cmp invocation:                        Invoking cmp.        (line   6)
5018008e37b6SJohn Marino* cmp options:                           cmp Options.         (line   6)
5019*6ea1f93eSDaniel Fojt* color, distinguishing different context: diff Options.      (line  37)
5020008e37b6SJohn Marino* columnar output:                       Side by Side.        (line   6)
5021008e37b6SJohn Marino* common mistakes with patches:          Avoiding Common Mistakes.
5022008e37b6SJohn Marino                                                              (line   6)
5023008e37b6SJohn Marino* comparing three files:                 Comparing Three Files.
5024008e37b6SJohn Marino                                                              (line   6)
5025008e37b6SJohn Marino* conflict:                              diff3 Merging.       (line  26)
5026008e37b6SJohn Marino* conflict marking:                      Marking Conflicts.   (line   6)
5027008e37b6SJohn Marino* context output format:                 Context.             (line   6)
5028008e37b6SJohn Marino* creating files:                        Creating and Removing.
5029008e37b6SJohn Marino                                                              (line   6)
5030*6ea1f93eSDaniel Fojt* de capability:                         diff Options.        (line 184)
5031008e37b6SJohn Marino* diagnostics from patch:                patch Messages.      (line   6)
5032008e37b6SJohn Marino* diff invocation:                       Invoking diff.       (line   6)
5033008e37b6SJohn Marino* diff merging:                          Interactive Merging. (line   6)
5034008e37b6SJohn Marino* diff options:                          diff Options.        (line   6)
5035008e37b6SJohn Marino* diff sample input:                     Sample diff Input.   (line   6)
5036008e37b6SJohn Marino* diff3 hunks:                           diff3 Hunks.         (line   6)
5037008e37b6SJohn Marino* diff3 invocation:                      Invoking diff3.      (line   6)
5038008e37b6SJohn Marino* diff3 options:                         diff3 Options.       (line   6)
5039008e37b6SJohn Marino* diff3 sample input:                    Sample diff3 Input.  (line   6)
5040008e37b6SJohn Marino* directories and patch:                 patch Directories.   (line   6)
5041008e37b6SJohn Marino* directory structure changes:           Changing Structure.  (line   6)
5042008e37b6SJohn Marino* dry runs for patch:                    Dry Runs.            (line   6)
5043008e37b6SJohn Marino* ed script output format:               ed Scripts.          (line   6)
5044008e37b6SJohn Marino* EDITOR:                                Merge Commands.      (line  50)
5045008e37b6SJohn Marino* empty files, removing:                 Creating and Removing.
5046008e37b6SJohn Marino                                                              (line   6)
5047*6ea1f93eSDaniel Fojt* exabyte, definition of:                cmp Options.         (line  99)
5048*6ea1f93eSDaniel Fojt* exbibyte, definition of:               cmp Options.         (line 102)
5049008e37b6SJohn Marino* file name alternates:                  Alternate Names.     (line   6)
5050008e37b6SJohn Marino* file names with unusual characters:    Unusual File Names.  (line   6)
5051008e37b6SJohn Marino* format of diff output:                 Output Formats.      (line   6)
5052008e37b6SJohn Marino* format of diff3 output:                Comparing Three Files.
5053008e37b6SJohn Marino                                                              (line   6)
5054008e37b6SJohn Marino* formats for if-then-else line groups:  Line Group Formats.  (line   6)
5055008e37b6SJohn Marino* forward ed script output format:       Forward ed.          (line   6)
5056008e37b6SJohn Marino* full lines:                            Incomplete Lines.    (line   6)
5057008e37b6SJohn Marino* function headings, C:                  C Function Headings. (line   6)
5058008e37b6SJohn Marino* fuzz factor when patching:             Inexact.             (line   6)
5059*6ea1f93eSDaniel Fojt* gibibyte, definition of:               cmp Options.         (line  87)
5060*6ea1f93eSDaniel Fojt* gigabyte, definition of:               cmp Options.         (line  84)
5061*6ea1f93eSDaniel Fojt* hd capability:                         diff Options.        (line 189)
5062008e37b6SJohn Marino* headings:                              Sections.            (line   6)
5063008e37b6SJohn Marino* hunks:                                 Hunks.               (line   6)
5064008e37b6SJohn Marino* hunks for diff3:                       diff3 Hunks.         (line   6)
5065008e37b6SJohn Marino* if-then-else output format:            If-then-else.        (line   6)
5066008e37b6SJohn Marino* ifdef output format:                   If-then-else.        (line   6)
5067008e37b6SJohn Marino* imperfect patch application:           Imperfect.           (line   6)
5068008e37b6SJohn Marino* incomplete line merging:               Merging Incomplete Lines.
5069008e37b6SJohn Marino                                                              (line   6)
5070008e37b6SJohn Marino* incomplete lines:                      Incomplete Lines.    (line   6)
5071008e37b6SJohn Marino* inexact patches:                       Inexact.             (line   6)
5072008e37b6SJohn Marino* inhibit messages from patch:           More or Fewer Messages.
5073008e37b6SJohn Marino                                                              (line   6)
5074008e37b6SJohn Marino* interactive merging:                   Interactive Merging. (line   6)
5075008e37b6SJohn Marino* introduction:                          Comparison.          (line   6)
5076008e37b6SJohn Marino* intuiting file names from patches:     Multiple Patches.    (line   6)
5077008e37b6SJohn Marino* invoking cmp:                          Invoking cmp.        (line   6)
5078008e37b6SJohn Marino* invoking diff:                         Invoking diff.       (line   6)
5079008e37b6SJohn Marino* invoking diff3:                        Invoking diff3.      (line   6)
5080008e37b6SJohn Marino* invoking patch:                        Invoking patch.      (line   6)
5081008e37b6SJohn Marino* invoking sdiff:                        Invoking sdiff.      (line   6)
5082008e37b6SJohn Marino* keyboard input to patch:               patch and Keyboard Input.
5083008e37b6SJohn Marino                                                              (line   6)
5084*6ea1f93eSDaniel Fojt* kibibyte, definition of:               cmp Options.         (line  75)
50854536c563SJohn Marino* kilobyte, definition of:               cmp Options.         (line  71)
5086008e37b6SJohn Marino* LC_COLLATE:                            Comparing Directories.
5087008e37b6SJohn Marino                                                              (line   6)
5088*6ea1f93eSDaniel Fojt* LC_NUMERIC:                            Line Group Formats.  (line 143)
5089008e37b6SJohn Marino* LC_TIME:                               Detailed Context.    (line  12)
5090008e37b6SJohn Marino* line formats:                          Line Formats.        (line   6)
5091008e37b6SJohn Marino* line group formats:                    Line Group Formats.  (line   6)
5092*6ea1f93eSDaniel Fojt* ln capability:                         diff Options.        (line 194)
5093*6ea1f93eSDaniel Fojt* mebibyte, definition of:               cmp Options.         (line  82)
5094*6ea1f93eSDaniel Fojt* megabyte, definition of:               cmp Options.         (line  79)
5095008e37b6SJohn Marino* merge commands:                        Merge Commands.      (line   6)
5096008e37b6SJohn Marino* merged diff3 format:                   Bypassing ed.        (line   6)
5097008e37b6SJohn Marino* merged output format:                  If-then-else.        (line   6)
5098008e37b6SJohn Marino* merging from a common ancestor:        diff3 Merging.       (line   6)
5099008e37b6SJohn Marino* merging interactively:                 Merge Commands.      (line   6)
5100008e37b6SJohn Marino* messages from patch:                   patch Messages.      (line   6)
5101008e37b6SJohn Marino* multibyte characters:                  Internationalization.
5102008e37b6SJohn Marino                                                              (line   6)
5103008e37b6SJohn Marino* multiple patches:                      Multiple Patches.    (line   6)
5104008e37b6SJohn Marino* newline treatment by diff:             Incomplete Lines.    (line   6)
5105*6ea1f93eSDaniel Fojt* none color option:                     diff Options.        (line  40)
5106008e37b6SJohn Marino* normal output format:                  Normal.              (line   6)
5107008e37b6SJohn Marino* options for cmp:                       cmp Options.         (line   6)
5108008e37b6SJohn Marino* options for diff:                      diff Options.        (line   6)
5109008e37b6SJohn Marino* options for diff3:                     diff3 Options.       (line   6)
5110008e37b6SJohn Marino* options for patch:                     patch Options.       (line   6)
5111008e37b6SJohn Marino* options for sdiff:                     sdiff Options.       (line   6)
5112008e37b6SJohn Marino* output formats:                        Output Formats.      (line   6)
5113008e37b6SJohn Marino* overlap:                               diff3 Merging.       (line  26)
5114008e37b6SJohn Marino* overlapping change, selection of:      Which Changes.       (line   6)
5115008e37b6SJohn Marino* overview of diff and patch:            Overview.            (line   6)
5116008e37b6SJohn Marino* paginating diff output:                Pagination.          (line   6)
5117008e37b6SJohn Marino* patch consumer tips:                   Tips for Patch Consumers.
5118008e37b6SJohn Marino                                                              (line   6)
5119008e37b6SJohn Marino* patch input format:                    patch Input.         (line   6)
5120008e37b6SJohn Marino* patch invocation:                      Invoking patch.      (line   6)
5121008e37b6SJohn Marino* patch messages and questions:          patch Messages.      (line   6)
5122008e37b6SJohn Marino* patch options:                         patch Options.       (line   6)
5123008e37b6SJohn Marino* patch producer tips:                   Tips for Patch Producers.
5124008e37b6SJohn Marino                                                              (line   6)
5125008e37b6SJohn Marino* patch, common mistakes:                Avoiding Common Mistakes.
5126008e37b6SJohn Marino                                                              (line   6)
5127008e37b6SJohn Marino* patches, shrinking:                    Generating Smaller Patches.
5128008e37b6SJohn Marino                                                              (line   6)
5129008e37b6SJohn Marino* patching directories:                  patch Directories.   (line   6)
5130*6ea1f93eSDaniel Fojt* PATCH_GET:                             Revision Control.    (line  13)
5131*6ea1f93eSDaniel Fojt* PATCH_VERSION_CONTROL:                 Backup Names.        (line  21)
5132*6ea1f93eSDaniel Fojt* pebibyte, definition of:               cmp Options.         (line  97)
5133008e37b6SJohn Marino* performance of diff:                   diff Performance.    (line   6)
5134*6ea1f93eSDaniel Fojt* petabyte, definition of:               cmp Options.         (line  94)
5135*6ea1f93eSDaniel Fojt* POSIX:                                 patch and POSIX.     (line   6)
5136008e37b6SJohn Marino* POSIX <1>:                             Standards conformance.
5137008e37b6SJohn Marino                                                              (line   6)
5138*6ea1f93eSDaniel Fojt* POSIXLY_CORRECT:                       patch and POSIX.     (line   6)
5139008e37b6SJohn Marino* POSIXLY_CORRECT <1>:                   Standards conformance.
5140008e37b6SJohn Marino                                                              (line   6)
5141008e37b6SJohn Marino* projects for directories:              Shortcomings.        (line   6)
5142008e37b6SJohn Marino* quoting style:                         patch Quoting Style. (line   6)
5143*6ea1f93eSDaniel Fojt* QUOTING_STYLE:                         patch Quoting Style. (line  26)
5144008e37b6SJohn Marino* RCS:                                   Revision Control.    (line   6)
5145008e37b6SJohn Marino* RCS script output format:              RCS.                 (line   6)
5146008e37b6SJohn Marino* regular expression matching headings:  Specified Headings.  (line   6)
5147008e37b6SJohn Marino* regular expression suppression:        Specified Lines.     (line   6)
5148008e37b6SJohn Marino* reject file names:                     Reject Names.        (line   6)
5149008e37b6SJohn Marino* removing empty files:                  Creating and Removing.
5150008e37b6SJohn Marino                                                              (line   6)
5151008e37b6SJohn Marino* reporting bugs:                        Bugs.                (line   6)
5152008e37b6SJohn Marino* reversed patches:                      Reversed Patches.    (line   6)
5153008e37b6SJohn Marino* revision control:                      Revision Control.    (line   6)
5154008e37b6SJohn Marino* sample input for diff:                 Sample diff Input.   (line   6)
5155008e37b6SJohn Marino* sample input for diff3:                Sample diff3 Input.  (line   6)
5156008e37b6SJohn Marino* SCCS:                                  Revision Control.    (line   6)
5157008e37b6SJohn Marino* script output formats:                 Scripts.             (line   6)
5158008e37b6SJohn Marino* sdiff invocation:                      Invoking sdiff.      (line   6)
5159008e37b6SJohn Marino* sdiff options:                         sdiff Options.       (line   6)
5160008e37b6SJohn Marino* sdiff output format:                   sdiff Option Summary.
5161008e37b6SJohn Marino                                                              (line   6)
5162008e37b6SJohn Marino* section headings:                      Sections.            (line   6)
5163008e37b6SJohn Marino* side by side:                          Side by Side.        (line   6)
5164008e37b6SJohn Marino* side by side format:                   Side by Side Format. (line   6)
5165008e37b6SJohn Marino* SIMPLE_BACKUP_SUFFIX:                  Backup Names.        (line  12)
5166008e37b6SJohn Marino* special files:                         Special Files.       (line   6)
5167008e37b6SJohn Marino* specified headings:                    Specified Headings.  (line   6)
5168008e37b6SJohn Marino* summarizing which files differ:        Brief.               (line   6)
5169008e37b6SJohn Marino* System V diff3 compatibility:          Saving the Changed File.
5170008e37b6SJohn Marino                                                              (line   6)
5171008e37b6SJohn Marino* tab and blank difference suppression:  White Space.         (line   6)
5172008e37b6SJohn Marino* tab stop alignment:                    Tabs.                (line   6)
5173*6ea1f93eSDaniel Fojt* tebibyte, definition of:               cmp Options.         (line  92)
5174*6ea1f93eSDaniel Fojt* terabyte, definition of:               cmp Options.         (line  89)
5175*6ea1f93eSDaniel Fojt* terminal, using color iff:             diff Options.        (line  42)
5176008e37b6SJohn Marino* testing patch:                         Dry Runs.            (line   6)
5177008e37b6SJohn Marino* text versus binary diff:               Binary.              (line   6)
5178008e37b6SJohn Marino* timestamp format, context diffs:       Detailed Context.    (line  12)
5179008e37b6SJohn Marino* timestamp format, unified diffs:       Detailed Unified.    (line  12)
5180*6ea1f93eSDaniel Fojt* timestamps on patched files:           Patching Timestamps. (line   6)
5181008e37b6SJohn Marino* traditional patch:                     patch and Tradition. (line   6)
5182008e37b6SJohn Marino* trailing blanks:                       Trailing Blanks.     (line   6)
5183008e37b6SJohn Marino* two-column output:                     Side by Side.        (line   6)
5184008e37b6SJohn Marino* unified output format:                 Unified Format.      (line   6)
5185008e37b6SJohn Marino* unmerged change:                       Which Changes.       (line   6)
5186008e37b6SJohn Marino* varying-width characters:              Internationalization.
5187008e37b6SJohn Marino                                                              (line   6)
5188008e37b6SJohn Marino* verbose messages from patch:           More or Fewer Messages.
5189008e37b6SJohn Marino                                                              (line   6)
5190008e37b6SJohn Marino* version control:                       Revision Control.    (line   6)
5191008e37b6SJohn Marino* VERSION_CONTROL:                       Revision Control.    (line  22)
5192*6ea1f93eSDaniel Fojt* VERSION_CONTROL <1>:                   Backup Names.        (line  21)
5193008e37b6SJohn Marino* white space in patches:                Changed White Space. (line   6)
5194*6ea1f93eSDaniel Fojt* yottabyte, definition of:              cmp Options.         (line 110)
5195*6ea1f93eSDaniel Fojt* zettabyte, definition of:              cmp Options.         (line 104)
5196008e37b6SJohn Marino
5197008e37b6SJohn Marino
5198008e37b6SJohn Marino
5199008e37b6SJohn MarinoTag Table:
5200*6ea1f93eSDaniel FojtNode: Top1431
5201*6ea1f93eSDaniel FojtNode: Overview3644
5202*6ea1f93eSDaniel FojtNode: Comparison7398
5203*6ea1f93eSDaniel FojtNode: Hunks10340
5204*6ea1f93eSDaniel FojtNode: White Space11781
5205*6ea1f93eSDaniel FojtNode: Blank Lines13620
5206*6ea1f93eSDaniel FojtNode: Specified Lines14609
5207*6ea1f93eSDaniel FojtNode: Case Folding15735
5208*6ea1f93eSDaniel FojtNode: Brief16152
5209*6ea1f93eSDaniel FojtNode: Binary17475
5210*6ea1f93eSDaniel FojtNode: Output Formats21272
5211*6ea1f93eSDaniel FojtNode: Sample diff Input21997
5212*6ea1f93eSDaniel FojtNode: Context23496
5213*6ea1f93eSDaniel FojtNode: Context Format25073
5214*6ea1f93eSDaniel FojtNode: Example Context25865
5215*6ea1f93eSDaniel FojtNode: Less Context27372
5216*6ea1f93eSDaniel FojtNode: Detailed Context28561
5217*6ea1f93eSDaniel FojtNode: Unified Format30756
5218*6ea1f93eSDaniel FojtNode: Example Unified31553
5219*6ea1f93eSDaniel FojtNode: Detailed Unified32591
5220*6ea1f93eSDaniel FojtNode: Sections34231
5221*6ea1f93eSDaniel FojtNode: Specified Headings34990
5222*6ea1f93eSDaniel FojtNode: C Function Headings36539
5223*6ea1f93eSDaniel FojtNode: Alternate Names37385
5224*6ea1f93eSDaniel FojtNode: Side by Side38298
5225*6ea1f93eSDaniel FojtNode: Side by Side Format40448
5226*6ea1f93eSDaniel FojtNode: Example Side by Side41350
5227*6ea1f93eSDaniel FojtNode: Normal42690
5228*6ea1f93eSDaniel FojtNode: Example Normal43691
5229*6ea1f93eSDaniel FojtNode: Detailed Normal44427
5230*6ea1f93eSDaniel FojtNode: Scripts46166
5231*6ea1f93eSDaniel FojtNode: ed Scripts46571
52324536c563SJohn MarinoNode: Example ed47777
5233*6ea1f93eSDaniel FojtNode: Detailed ed48227
5234*6ea1f93eSDaniel FojtNode: Forward ed49986
5235*6ea1f93eSDaniel FojtNode: RCS50762
5236*6ea1f93eSDaniel FojtNode: If-then-else51978
5237*6ea1f93eSDaniel FojtNode: Line Group Formats53656
5238*6ea1f93eSDaniel FojtNode: Line Formats59537
5239*6ea1f93eSDaniel FojtNode: Example If-then-else62806
5240*6ea1f93eSDaniel FojtNode: Detailed If-then-else63885
5241*6ea1f93eSDaniel FojtNode: Incomplete Lines65770
5242*6ea1f93eSDaniel FojtNode: Comparing Directories67406
5243*6ea1f93eSDaniel FojtNode: Adjusting Output71698
5244*6ea1f93eSDaniel FojtNode: Tabs72205
5245*6ea1f93eSDaniel FojtNode: Trailing Blanks73819
5246*6ea1f93eSDaniel FojtNode: Pagination75044
5247*6ea1f93eSDaniel FojtNode: diff Performance75512
5248*6ea1f93eSDaniel FojtNode: Comparing Three Files78601
5249*6ea1f93eSDaniel FojtNode: Sample diff3 Input79479
5250*6ea1f93eSDaniel FojtNode: Example diff3 Normal80427
5251*6ea1f93eSDaniel FojtNode: Detailed diff3 Normal81487
5252*6ea1f93eSDaniel FojtNode: diff3 Hunks83275
5253*6ea1f93eSDaniel FojtNode: diff3 Merging84541
5254*6ea1f93eSDaniel FojtNode: Which Changes86786
5255*6ea1f93eSDaniel FojtNode: Marking Conflicts88186
5256*6ea1f93eSDaniel FojtNode: Bypassing ed90641
5257*6ea1f93eSDaniel FojtNode: Merging Incomplete Lines91984
5258*6ea1f93eSDaniel FojtNode: Saving the Changed File92710
5259*6ea1f93eSDaniel FojtNode: Interactive Merging93326
5260*6ea1f93eSDaniel FojtNode: sdiff Option Summary94035
5261*6ea1f93eSDaniel FojtNode: Merge Commands95238
5262*6ea1f93eSDaniel FojtNode: Merging with patch96527
5263*6ea1f93eSDaniel FojtNode: patch Input98894
5264*6ea1f93eSDaniel FojtNode: Revision Control99576
5265*6ea1f93eSDaniel FojtNode: Imperfect100746
5266*6ea1f93eSDaniel FojtNode: Changed White Space101895
5267*6ea1f93eSDaniel FojtNode: Reversed Patches102692
5268*6ea1f93eSDaniel FojtNode: Inexact104156
5269*6ea1f93eSDaniel FojtNode: Dry Runs107712
5270*6ea1f93eSDaniel FojtNode: Creating and Removing108576
5271*6ea1f93eSDaniel FojtNode: Patching Timestamps109625
5272*6ea1f93eSDaniel FojtNode: Multiple Patches111812
5273*6ea1f93eSDaniel FojtNode: patch Directories114473
5274*6ea1f93eSDaniel FojtNode: Backups116097
5275*6ea1f93eSDaniel FojtNode: Backup Names117161
5276*6ea1f93eSDaniel FojtRef: Backup Names-Footnote-1120116
5277*6ea1f93eSDaniel FojtNode: Reject Names120243
5278*6ea1f93eSDaniel FojtNode: patch Messages120832
5279*6ea1f93eSDaniel FojtNode: More or Fewer Messages121892
5280*6ea1f93eSDaniel FojtNode: patch and Keyboard Input122523
5281*6ea1f93eSDaniel FojtNode: patch Quoting Style123552
5282*6ea1f93eSDaniel FojtNode: patch and POSIX124698
5283*6ea1f93eSDaniel FojtNode: patch and Tradition125537
5284*6ea1f93eSDaniel FojtNode: Making Patches128958
5285*6ea1f93eSDaniel FojtNode: Tips for Patch Producers129784
5286*6ea1f93eSDaniel FojtNode: Tips for Patch Consumers131039
5287*6ea1f93eSDaniel FojtNode: Avoiding Common Mistakes131676
5288*6ea1f93eSDaniel FojtNode: Generating Smaller Patches134201
5289*6ea1f93eSDaniel FojtNode: Invoking cmp135960
5290*6ea1f93eSDaniel FojtNode: cmp Options137510
5291*6ea1f93eSDaniel FojtNode: Invoking diff141154
5292*6ea1f93eSDaniel FojtNode: diff Options142773
5293*6ea1f93eSDaniel FojtNode: Invoking diff3152622
5294*6ea1f93eSDaniel FojtNode: diff3 Options153260
5295*6ea1f93eSDaniel FojtNode: Invoking patch156293
5296*6ea1f93eSDaniel FojtNode: patch Options157501
5297*6ea1f93eSDaniel FojtNode: Invoking sdiff162721
5298*6ea1f93eSDaniel FojtNode: sdiff Options163863
5299*6ea1f93eSDaniel FojtNode: Standards conformance166835
5300*6ea1f93eSDaniel FojtNode: Projects168581
5301*6ea1f93eSDaniel FojtNode: Shortcomings169293
5302*6ea1f93eSDaniel FojtNode: Internationalization170393
5303*6ea1f93eSDaniel FojtNode: Changing Structure171559
5304*6ea1f93eSDaniel FojtNode: Special Files172662
5305*6ea1f93eSDaniel FojtNode: Unusual File Names173773
5306*6ea1f93eSDaniel FojtNode: Timestamp Order174411
5307*6ea1f93eSDaniel FojtNode: Ignoring Changes175047
5308*6ea1f93eSDaniel FojtNode: Speedups175816
5309*6ea1f93eSDaniel FojtNode: Bugs176278
5310*6ea1f93eSDaniel FojtNode: Copying This Manual177131
5311*6ea1f93eSDaniel FojtNode: Translations202252
5312*6ea1f93eSDaniel FojtNode: Index202624
5313008e37b6SJohn Marino
5314008e37b6SJohn MarinoEnd Tag Table
5315