207 lines
3.7 KiB
Groff
207 lines
3.7 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g1.diff3 @(#)diff3 30.2 of 12/25/85
|
|
.nr X
|
|
.if \nX=0 .ds x} DIFF3 1 "Directory and File Management Utilities" "\&"
|
|
.if \nX=1 .ds x} DIFF3 1 "Directory and File Management Utilities"
|
|
.if \nX=2 .ds x} DIFF3 1 "" "\&"
|
|
.if \nX=3 .ds x} DIFF3 "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
diff3 \- 3-way differential file comparison
|
|
.SH SYNOPSIS
|
|
.B diff3
|
|
[
|
|
.B \-exEX3
|
|
.RB [ \-i " | " -m ]
|
|
.RB [ -L
|
|
label1
|
|
.B -L
|
|
label3]
|
|
]
|
|
file1 file2 file3
|
|
.SH DESCRIPTION
|
|
.I Diff3
|
|
compares three versions of a file,
|
|
and publishes disagreeing ranges of text
|
|
flagged with these codes:
|
|
.TP 16
|
|
====
|
|
all three files differ
|
|
.TP 16
|
|
====1
|
|
.IR file1 " is different"
|
|
.TP 16
|
|
====2
|
|
.IR file2 " is different"
|
|
.TP 16
|
|
====3
|
|
.IR file3 " is different"
|
|
.PP
|
|
The type of change suffered in converting a given range
|
|
of a given file to some other is
|
|
indicated in one of these ways:
|
|
.TP 16
|
|
.IB f " : " n1 " a"
|
|
Text is to be appended after line number
|
|
.I n1
|
|
in file
|
|
.I f,
|
|
where
|
|
.I f
|
|
= 1, 2, or 3.
|
|
.TP 16
|
|
.IB f " : " n1 " , " n2 " c"
|
|
Text is to be
|
|
changed in the range line
|
|
.I n1
|
|
to line
|
|
.IR n2 .
|
|
If
|
|
.I n1
|
|
=
|
|
.I n2,
|
|
the range may be abbreviated to
|
|
.IR n1 .
|
|
.PP
|
|
The original contents of the range follows immediately
|
|
after a
|
|
.B c
|
|
indication.
|
|
When the contents of two
|
|
files are identical, the contents of the lower-numbered
|
|
file is suppressed.
|
|
.PP
|
|
The
|
|
.B \-m
|
|
option produces a merge script
|
|
on the output of
|
|
.IR diff3 .
|
|
If none of
|
|
.B \-eExX3
|
|
is specified along with
|
|
.BR \-m ,
|
|
then the format of option
|
|
.B \-E
|
|
is presumed.
|
|
If the
|
|
.B \-m
|
|
option is used,
|
|
then binary files, files without
|
|
trailing newline, and files with
|
|
excessively long lines can be
|
|
successfully merged.
|
|
.PP
|
|
If no
|
|
.B \-m
|
|
option is specified, then
|
|
under the
|
|
.B \-e
|
|
option,
|
|
.I diff3
|
|
publishes a script for the editor
|
|
.IR ed (1)
|
|
that will incorporate into
|
|
.I file1
|
|
all changes between
|
|
.I file2
|
|
and
|
|
.I file3,
|
|
.IR i.e .
|
|
the changes that normally would be flagged ==== and ====3.
|
|
Option
|
|
.B \-x
|
|
(\f3\-3\f1)
|
|
produces a script to incorporate
|
|
only changes flagged ==== (====3).
|
|
The following command will apply the resulting script to
|
|
`file1', and emit the result on the output stream.
|
|
.PP
|
|
.ti 16n
|
|
(cat script; echo \(fm1,$p\(fm) \(bv ed \- file1
|
|
.PP
|
|
The
|
|
.B \-E
|
|
and
|
|
.B \-X
|
|
are similar to
|
|
.B \-e
|
|
and
|
|
.BR \-x ,
|
|
respectively, but treat overlapping changes (i.e., changes that would
|
|
be flagged with ==== in the normal listing) differently. The overlapping
|
|
lines from both files will be inserted by the edit script, bracketed
|
|
by "<<<<<<" and ">>>>>>" lines.
|
|
.PP
|
|
For example, suppose lines 7-8 are changed in both file1 and file3.
|
|
The merged output of the command
|
|
.sp
|
|
.ce
|
|
"diff3 -m file1 file2 file3"
|
|
.br
|
|
contains:
|
|
.RS
|
|
.nf
|
|
|
|
lines 1-6 of file1
|
|
<<<<<<< file1
|
|
lines 7-8 of file1
|
|
=======
|
|
lines 7-8 of file3
|
|
>>>>>>> file3
|
|
rest of file1
|
|
.fi
|
|
.RE
|
|
.PP
|
|
If there are overlaps, the user should edit the result and delete one of the
|
|
alternatives.
|
|
If the
|
|
.BI \-L "\ label1"
|
|
and
|
|
.BI \-L "\ label3"
|
|
options are given, the labels are output in place of the names
|
|
.I file1
|
|
and
|
|
.I file3
|
|
in overlap reports.
|
|
.PP
|
|
If the option
|
|
.B \-i
|
|
is specified along with one of the options
|
|
.BR \-exEX3 ,
|
|
then the resulting edit script has the editor
|
|
commands
|
|
.sp
|
|
.nf
|
|
w
|
|
q
|
|
.fi
|
|
.PP
|
|
added at the end.
|
|
Then the following command will update
|
|
`file1' in place with the changes.
|
|
.PP
|
|
.ti 16n
|
|
ed \- file1 < script
|
|
.SH "SEE ALSO"
|
|
diff(1),
|
|
ed(1).
|
|
.SH BUGS
|
|
If merges are done by generating explicit scripts
|
|
to input to the editor, rather than by using the
|
|
.B \-m
|
|
option, the merge is limited by the capabilities
|
|
of the editor
|
|
.IR ed (1).
|
|
The editor cannot handle excessively long lines,
|
|
binary files (with nul bytes)
|
|
or files without a trailing newline.
|
|
.SH DIAGNOSTICS
|
|
An exit status of 0 means
|
|
.I diff3
|
|
was successful,
|
|
1 means some overlaps were found,
|
|
and 2 means trouble.
|
|
.\" @(#)diff3.1 6.2 of 9/2/83
|
|
.Ee
|
|
'\".so /pubs/tools/origin.bsd
|