.\"
.\" This code contains changes by
.\" Gunnar Ritter, Freiburg i. Br., Germany, March 2003. All rights reserved.
.\"
.\" Conditions 1, 2, and 4 and the no-warranty notice below apply
.\" to these changes.
.\"
.\"
.\" Copyright (c) 1980, 1993
.\" 	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowedgement:
.\" 	This product includes software developed by the University of
.\" 	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"
.\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"   Redistributions of source code and documentation must retain the
.\"    above copyright notice, this list of conditions and the following
.\"    disclaimer.
.\"   Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"   All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"      This product includes software developed or owned by Caldera
.\"      International, Inc.
.\"   Neither the name of Caldera International, Inc. nor the names of
.\"    other contributors may be used to endorse or promote products
.\"    derived from this software without specific prior written permission.
.\"
.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
.\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\"	from 4.3BSD diff3.1	6.2 (Berkeley) 8/20/85
.\"
.\"	Sccsid @(#)diff3.1	1.3 (gritter) 10/11/03
.\"
.TH DIFF3 1 "10/11/03" "Heirloom Toolchest" "User Commands"
.SH NAME
diff3 \- 3-way differential file comparison
.SH SYNOPSIS
\fBdiff3\fR [\fB\-exEX3\fR] \fIfile1 file2 file3\fR
.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
Under the
.B \-e
option,
.I diff3
publishes a script for the editor
.I ed
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
(\fB\-3\fR)
produces a script to incorporate
only changes flagged ==== (====3).
The following command will apply the resulting script to
`file1'.
.PP
.ti 16n
(cat script; echo \'1,$p\') \(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 file2.
Applying the edit script generated by the command
.ce
"diff3 -E file1 file2 file3" 
.br
to file1 results in the file:
.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
.\"The
.\".B \-E
.\"option is used by RCS
.\".IR merge (1)
.\"to insure that overlapping changes in the merged files are preserved
.\"and brought to someone's attention.
.SH FILES
/tmp/d3?????
.br
/usr/5lib/diff3prog
.SH "SEE ALSO"
diff(1)
.SH NOTES
Text lines that consist of a single `.' will
defeat
.B \-e.
