home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
gnu
/
info
/
diff.info-1
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-09-02
|
47KB
|
894 lines
This is Info file diff.info, produced by Makeinfo-1.55 from the input
file ./diff.texi.
This file documents the the GNU `diff', `diff3', `sdiff', and `cmp'
commands for showing the differences between text files and the `patch'
command for using their output to update files.
Copyright (C) 1992, 1993 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.
File: diff.info, Node: Top, Up: (dir)
This file documents the the GNU `diff', `diff3', `sdiff', and `cmp'
commands for showing the differences between text files and the `patch'
command for using their output to update files.
This is Edition 1.2, for `diff' 2.4 and `patch' 2.1.
* Menu:
* Overview:: Preliminary information.
* Comparison:: What file comparison means.
* Output Formats:: Formats for difference reports.
* Comparing Directories:: Comparing files and directories.
* Adjusting Output:: Making `diff' output prettier.
* diff Performance:: Making `diff' smarter or faster.
* Comparing Three Files:: Formats for three-way difference reports.
* diff3 Merging:: Merging from a common ancestor.
* Interactive Merging:: Interactive merging with `sdiff'.
* Merging with patch:: Using `patch' to change old files into new ones.
* Making Patches:: Tips for making patch distributions.
* Invoking cmp:: How to run `cmp' and a summary of its options.
* Invoking diff:: How to run `diff' and a summary of its options.
* Invoking diff3:: How to run `diff3' and a summary of its options.
* Invoking patch:: How to run `patch' and a summary of its options.
* Invoking sdiff:: How to run `sdiff' and a summary of its options.
* Incomplete Lines:: Lines that lack trailing newlines.
* Projects:: If you think you've found a bug or other shortcoming.
* Concept Index:: Index of concepts.
File: diff.info, Node: Overview, Next: Comparison, Up: Top
Overview
********
Computer users often find occasion to ask how two files differ.
Perhaps one file is a newer version of the other file. Or maybe the
two files started out as identical copies but were changed by different
people.
You can use the `diff' command to show differences between two
files, or each corresponding file in two directories. `diff' outputs
differences between files line by line in any of several formats,
selectable by command line options. This set of differences is often
called a "diff" or "patch". For files that are identical, `diff'
normally produces no output; for binary (non-text) files, `diff'
normally reports only that they are different.
You can use the `cmp' command to show the offsets and line numbers
where two files differ. `cmp' can also show all the characters that
differ between the two files, side by side. Another way to compare two
files character by character is the Emacs command `M-x
compare-windows'. *Note Other Window: (emacs)Other Window, for more
information on that command.
You can use the `diff3' command to show differences among three
files. When two people have made independent changes to a common
original, `diff3' can report the differences between the original and
the two changed versions, and can produce a merged file that contains
both persons' changes together with warnings about conflicts.
You can use the `sdiff' command to merge two files interactively.
You can use the set of differences produced by `diff' to distribute
updates to text files (such as program source code) to other people.
This method is especially useful when the differences are small compared
to the complete files. Given `diff' output, you can use the `patch'
program to update, or "patch", a copy of the file. If you think of
`diff' as subtracting one file from another to produce their
difference, you can think of `patch' as adding the difference to one
file to reproduce the other.
This manual first concentrates on making diffs, and later shows how
to use diffs to update files.
GNU `diff' was written by Mike Haertel, David Hayes, Richard
Stallman, Len Tower, and Paul Eggert. Wayne Davison designed and
implemented the unified output format. The basic algorithm is described
in "An O(ND) Difference Algorithm and its Variations", Eugene W. Myers,
`Algorithmica' Vol. 1 No. 2, 1986, pp. 251-266; and in "A File
Comparison Program", Webb Miller and Eugene W. Myers,
`Software--Practice and Experience' Vol. 15 No. 11, 1985, pp. 1025-1040.
The algorithm was independently discovered as described in "Algorithms
for Approximate String Matching", E. Ukkonen, `Information and Control'
Vol. 64, 1985, pp. 100-118.
GNU `diff3' was written by Randy Smith. GNU `sdiff' was written by
Thomas Lord. GNU `cmp' was written by Torbjorn Granlund and David
MacKenzie.
`patch' was written mainly by Larry Wall; the GNU enhancements were
written mainly by Wayne Davison and David MacKenzie. Parts of this
manual are adapted from a manual page written by Larry Wall, with his
permission.
File: diff.info, Node: Comparison, Next: Output Formats, Prev: Overview, Up: Top
What Comparison Means
*********************
There are several ways to think about the differences between two
files. One way to think of the differences is as a series of lines
that were deleted from, inserted in, or changed in one file to produce
the other file. `diff' compares two files line by line, finds groups of
lines that differ, and reports each group of differing lines. It can
report the differing lines in several formats, which have different
purposes.
GNU `diff' can show whether files are different without detailing
the differences. It also provides ways to suppress certain kinds of
differences that are not important to you. Most commonly, such
differences are changes in the amount of white space between words or
lines. `diff' also provides ways to suppress differences in alphabetic
case or in lines that match a regular expression that you provide.
These options can accumulate; for example, you can ignore changes in
both white space and alphabetic case.
Another way to think of the differences between two files is as a
sequence of pairs of characters that can be either identical or
different. `cmp' reports the differences between two files character
by character, instead of line by line. As a result, it is more useful
than `diff' for comparing binary files. For text files, `cmp' is
useful mainly when you want to know only whether two files are
identical.
To illustrate the effect that considering changes character by
character can have compared with considering them line by line, think
of what happens if a single newline character is added to the beginning
of a file. If that file is then compared with an otherwise identical
file that lacks the newline at the beginning, `diff' will report that a
blank line has been added to the file, while `cmp' will report that
almost every character of the two files differs.
`diff3' normally compares three input files line by line, finds
groups of lines that differ, and reports each group of differing lines.
Its output is designed to make it easy to inspect two different sets of
changes to the same file.
* Menu:
* Hunks:: Groups of differing lines.
* White Space:: Suppressing differences in white space.
* Blank Lines:: Suppressing differences in blank lines.
* Case Folding:: Suppressing differences in alphabetic case.
* Specified Folding:: Suppressing differences that match regular expressions.
* Brief:: Summarizing which files are different.
* Binary:: Comparing binary files or forcing text comparisons.
File: diff.info, Node: Hunks, Next: White Space, Up: Comparison