xref: /openbsd-src/usr.bin/diff3/diff3.1 (revision c5f4fad510dd427c0c20c0f4d164f60ce24651b6)
1.\" $OpenBSD: diff3.1,v 1.4 2004/07/07 14:28:23 jaredy Exp $
2.\"
3.\" Copyright (c) 1990, 1993, 1994
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)diff3.1	8.2 (Berkeley) 4/18/94
31.\"
32.Dd April 18, 1994
33.Dt DIFF3 1
34.Os
35.Sh NAME
36.Nm diff3
37.Nd 3-way differential file comparison
38.Sh SYNOPSIS
39.Nm diff3
40.Op Fl aexEX3
41.Ar file1 file2 file3
42.Sh DESCRIPTION
43The
44.Nm
45utility compares the contents of three different versions of a file,
46.Ar file1 ,
47.Ar file2
48and
49.Ar file3 ,
50writing the result to the standard output.
51The options describe different methods of merging and
52purging
53the separate versions into a new file.
54.Nm
55is used by
56.Xr rcs 1
57to merge specific versions or create
58new versions.
59.Pp
60The options are as follows:
61.Bl -tag -width "-E, -X"
62.It Fl a
63Treat all files as ASCII.
64.It Fl e
65Produces output in a form suitable as an input script for the
66.Xr ed 1
67utility.
68The script may then be used to merge differences common between all
69three files and differences specific to
70.Ar file1
71and
72.Ar file3 .
73In other words, the
74.Fl e
75option ignores differences specific to
76.Ar file1
77and
78.Ar file2 ,
79and those specific to
80.Ar file2
81and
82.Ar file3 .
83It is useful for backing out changes specific to
84.Ar file2
85only.
86.It Fl x
87Produces an output script suitable for
88.Xr ed 1
89with changes
90specific only to all three versions.
91.It Fl 3
92Produces an output script suitable for
93.Xr ed 1
94with changes
95specific only to
96.Ar file3 .
97.It Fl E , X
98Similar to
99.Fl e
100and
101.Fl x ,
102respectively, but treat overlapping changes (i.e., changes that would
103be noted with ==== in the normal listing) differently.
104The overlapping lines from both files will be inserted by the edit script,
105bracketed by "<<<<<<" and ">>>>>>" lines.
106.El
107.Pp
108The
109.Fl E
110option is used by
111.Tn RCS
112.Xr merge 1
113to ensure that overlapping changes in the merged files are preserved
114and brought to someone's attention.
115.Pp
116For example, suppose lines 7-8 are changed in both
117.Ar file1
118and
119.Ar file2 .
120Applying the edit script generated by the command
121.Pp
122.Dl $ diff3 -E file1 file2 file3
123.Pp
124to
125.Ar file1
126results in the file:
127.Bd -literal -offset indent
128lines 1-6
129of file1
130<<<<<<< file1
131lines 7-8
132of file1
133=======
134lines 7-8
135of file3
136>>>>>>> file3
137rest of file1
138.Ed
139.Pp
140The default output of
141.Nm
142makes notation of the differences between all files, and those
143differences specific to each pair of files.
144The changes are described by the commands necessary for
145.Xr ed 1
146to create the desired target from the different versions.
147See
148.Xr diff 1
149for a description of the commands.
150.Bl -tag -width "====="
151.It Li \&====
152The lines beneath this notation are ranges of lines which are different
153between all files.
154.It \&==== Ns Va n
155The lines beneath this notation are ranges of lines which are exclusively
156different in file
157.Va n .
158.El
159.Sh ENVIRONMENT
160.Bl -tag -width TMPDIR
161.It Ev TMPDIR
162If the environment variable
163.Ev TMPDIR
164exists,
165.Nm
166will use the directory specified by
167.Ev TMPDIR
168as the temporary directory.
169.El
170.Sh FILES
171.Bl -tag -width /usr/libexec/diff3prog -compact
172.It Pa /tmp/d3a.XXXXXXXXXX
173temporary file
174.It Pa /tmp/d3b.XXXXXXXXXX
175temporary file
176.It Pa /usr/libexec/diff3prog
177the actual executable
178.El
179.Sh SEE ALSO
180.Xr diff 1 ,
181.Xr ed 1 ,
182.Xr merge 1 ,
183.Xr rcs 1
184.Sh HISTORY
185A
186.Nm
187command appeared in
188.At v7 .
189.Sh BUGS
190The
191.Fl e
192option cannot catch and change lines which have
193.Ql \&.
194as the first and only character on the line.
195The resulting script will fail on that line
196as
197.Ql \&.
198is an
199.Xr ed 1
200editing command.
201