xref: /original-bsd/usr.bin/diff/diff3/diff3.1 (revision f5cc5b3e)
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)diff3.1	6.3 (Berkeley) 06/24/90
7.\"
8.Dd
9.Dt DIFF3 1
10.Os BSD 4.4
11.Sh NAME
12.Nm diff3
13.Nd 3-way differential file comparison
14.Sh SYNOPSIS
15.Nm diff3
16.Op Fl exEX3
17.Ar file1 file2 file3
18.Sh DESCRIPTION
19The
20.Nm diff3
21utility compares the contents of three different versions of a file,
22.Ar file1 ,
23.Ar file2
24and
25.Ar file3 ,
26writing the result to the standard output.
27The options describe different methods of merging and
28purging
29the separate versions into a new file.
30.Nm Diff3
31is used by
32.Xr RCS 1
33to merge specific versions or create
34new versions.
35.Pp
36Options are:
37.Tp Fl e
38Produces output in a form suitable as an input script for the
39.Xr ed 1
40utility.  The script may then be used to merge differences common
41between all three files and differences specific to file1 and file3.
42In other words, the
43.Fl e
44option ignores differences specific to file1 and file2, and those
45specific to file2 and file3.  It is useful for backing out changes
46specific to file2 only.
47.Tp Fl x
48Produces an output script suitable for
49.Xr ed 1
50with changes
51specific only to all three versions.
52.Tp Fl 3
53Produces an output script suitable for
54.Xr ed 1
55with changes
56specific only to file3.
57.Tp Fl E , X
58Similar to
59.Fl e
60and
61.Fl x  ,
62respectively, but treat overlapping changes (i.e., changes that would
63be noted with ==== in the normal listing) differently.  The overlapping
64lines from both files will be inserted by the edit script, bracketed
65by "<<<<<<" and ">>>>>>" lines.
66.Tp
67.Pp
68The
69.Fl E
70option is used by RCS
71.Xr merge  1
72to insure that overlapping changes in the merged files are preserved
73and brought to someone's attention.
74.Pp
75For example, suppose lines 7-8 are changed in both file1 and file2.
76Applying the edit script generated by the command
77.Pp
78.Dl diff3 -E file1 file2 file3
79.Pp
80to file1 results in the file:
81.Ds I
82lines 1-6
83of file1
84<<<<<<< file1
85lines 7-8
86of file1
87=======
88lines 7-8
89of file3
90>>>>>>> file3
91rest of file1
92.De
93.Pp
94The default output of
95.Nm diff3
96makes notation of the differences between all files, and those differences
97specific to each pair of files. The
98changes are described by
99the commands neccessary for
100.Xr ed 1
101to create the desired target from the different versions.
102See
103.Xr diff 1
104for a description of the commands.
105.Tw Fl
106.Tp Li \&====
107The lines beneath this notation are ranges of lines which are different
108between all files.
109.Tc Li \&====
110.Va n
111.Cx
112The lines beneath this notation are ranges of lines which are exclusively
113different in file
114.Va n .
115.Tp
116.Sh EXAMPLES
117.Pp
118If three files were to contain:
119.Ds I
120.Cw  mooxthree mooxthree mooxthree
121.Cl file1	file2	file3
122.Cl moo	moo	moo
123.Cl moo too	moon	moon
124.Cl moo three	moo moo	moo moo
125.Cl tangent	beam	milk
126.Cl moo moo	sun	butter
127.Cl \tcloud	beam
128.Cl \tmoo moo
129.Cl \tmoo moo
130.Cw
131.De
132.Pp
133The command line
134.Pp
135.Dl diff3 -e file1 file2 file3
136.Pp
137produces the following ed script:
138.Pp
139.Ds C
140====1
1411:2,4c
142  moo two
143  moo three
144  tangent
1452:2c
1463:2c
147  moon
148====
1491:5a
1502:4,8c
151  beam
152  sun
153  cloud
154  moo moo
155  moo moo
1563:4,6c
157  milk
158  butter
159  beam
160.De
161.Sh FILES
162.Dw /usr/bin/diff3
163.Di L
164.Dp Pa /tmp/d3?????
165temporary files.
166.Dp Pa /usr/bin/diff3
167the executable.
168.Dp
169.Sh SEE ALSO
170.Xr diff 1
171.Xr ed 1
172.Xr rcs 1
173.Sh HISTORY
174.Nm Diff3
175appeared in Version 7 AT&T Unix.
176.Sh BUGS
177The
178.Fl e
179option
180cannot catch and change
181lines which have
182.Sq Li \&.
183as the first ans only character on the line.
184The resulting script will fail on that line
185as the
186.Sq Li \&.
187is an
188.Xr ed 1
189editing command.
190