xref: /freebsd/usr.bin/diff3/diff3.1 (revision bc5304a006238115291e7568583632889dffbab9)
1.\" $OpenBSD: diff3.1,v 1.7 2007/05/31 19:20:09 jmc 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.\" $FreeBSD$
32.\"
33.Dd May 25, 2017
34.Dt DIFF3 1
35.Os
36.Sh NAME
37.Nm diff3
38.Nd 3-way differential file comparison
39.Sh SYNOPSIS
40.Nm diff3
41.Op Fl 3aEeiXx
42.Op Fl Fl diff-program Ar program
43.Op Fl Fl strip-trailing-cr
44.Op Fl L | Fl Fl label Ar label1
45.Op Fl L | Fl Fl label Ar label2
46.Op Fl L | Fl Fl label Ar label3
47.Ar file1 file2 file3
48.Sh DESCRIPTION
49The
50.Nm
51utility compares the contents of three different versions of a file,
52.Ar file1 ,
53.Ar file2
54and
55.Ar file3 ,
56writing the result to the standard output.
57The options describe different methods of merging and
58purging
59the separate versions into a new file.
60.Nm
61is used by
62.Xr rcs 1
63to merge specific versions or create
64new versions.
65.Pp
66The options are as follows:
67.Bl -tag -width "-E, -X"
68.It Fl 3 , Fl Fl easy-only
69Produces an output script suitable for
70.Xr ed 1
71with changes
72specific only to
73.Ar file3 .
74.It Fl a , Fl Fl text
75Treat all files as ASCII.
76.It Fl E , Fl Fl show-overlap
77.It Fl X
78Similar to
79.Fl e
80and
81.Fl x ,
82respectively, but treat overlapping changes (i.e., changes that would
83be noted with ==== in the normal listing) differently.
84The overlapping lines from both files will be inserted by the edit script,
85bracketed by "<<<<<<" and ">>>>>>" lines.
86.It Fl e , Fl Fl ed
87Produces output in a form suitable as an input script for the
88.Xr ed 1
89utility.
90The script may then be used to merge differences common between all
91three files and differences specific to
92.Ar file1
93and
94.Ar file3 .
95In other words, the
96.Fl e
97option ignores differences specific to
98.Ar file1
99and
100.Ar file2 ,
101and those specific to
102.Ar file2
103and
104.Ar file3 .
105It is useful for backing out changes specific to
106.Ar file2
107only.
108.It Fl i
109Appends 'w' and 'q'
110.Xr ed 1
111commands.
112.It Fl L , Fl Fl label
113Defines labels to print instead of file names
114.Ar file1 ,
115.Ar file2
116and
117.Ar file3 .
118.It Fl x, Fl Fl overlap-only
119Produces an output script suitable for
120.Xr ed 1
121with changes
122specific only to all three versions.
123.It Fl Fl diff-program Ar program
124Use
125.Ar program
126instead of the default
127.Xr diff 1
128to compare files.
129.It Fl Fl strip-trailing-cr
130Strip trailing carriage return on input files.
131.El
132.Pp
133The
134.Fl E
135option is used by
136.Tn RCS
137.Xr merge 1
138to ensure that overlapping changes in the merged files are preserved
139and brought to someone's attention.
140.Pp
141For example, suppose lines 7-8 are changed in both
142.Ar file1
143and
144.Ar file2 .
145Applying the edit script generated by the command
146.Pp
147.Dl $ diff3 -E file1 file2 file3
148.Pp
149to
150.Ar file1
151results in the file:
152.Bd -literal -offset indent
153lines 1-6
154of file1
155<<<<<<< file1
156lines 7-8
157of file1
158=======
159lines 7-8
160of file3
161>>>>>>> file3
162rest of file1
163.Ed
164.Pp
165The default output of
166.Nm
167makes notation of the differences between all files, and those
168differences specific to each pair of files.
169The changes are described by the commands necessary for
170.Xr ed 1
171to create the desired target from the different versions.
172See
173.Xr diff 1
174for a description of the commands.
175.Bl -tag -width "====="
176.It Li \&====
177The lines beneath this notation are ranges of lines which are different
178between all files.
179.It \&==== Ns Va n
180The lines beneath this notation are ranges of lines which are exclusively
181different in file
182.Va n .
183.El
184.Sh SEE ALSO
185.Xr diff 1 ,
186.Xr ed 1 ,
187.Xr merge 1 ,
188.Xr rcs 1 ,
189.Xr sdiff 1
190.Sh HISTORY
191A
192.Nm
193command appeared in
194.At v7 .
195.Sh BUGS
196The
197.Fl e
198option cannot catch and change lines which have
199.Ql \&.
200as the first and only character on the line.
201The resulting script will fail on that line
202as
203.Ql \&.
204is an
205.Xr ed 1
206editing command.
207