xref: /csrg-svn/usr.bin/diff/diff3/diff3.1 (revision 43687)
1*43687Scael.\" Copyright (c) 1990 The Regents of the University of California.
2*43687Scael.\" All rights reserved.
319405Smckusick.\"
4*43687Scael.\" %sccs.include.redist.man%
5*43687Scael.\"
6*43687Scael.\"     @(#)diff3.1	6.3 (Berkeley) 06/24/90
7*43687Scael.\"
8*43687Scael.Dd
9*43687Scael.Dt DIFF3 1
10*43687Scael.Os BSD 4.4
11*43687Scael.Sh NAME
12*43687Scael.Nm diff3
13*43687Scael.Nd 3-way differential file comparison
14*43687Scael.Sh SYNOPSIS
15*43687Scael.Nm diff3
16*43687Scael.Op Fl exEX3
17*43687Scael.Ar file1 file2 file3
18*43687Scael.Sh DESCRIPTION
1924333SvanThe
20*43687Scael.Nm diff3
21*43687Scaelutility compares the contents of three different versions of a file,
22*43687Scael.Ar file1 ,
23*43687Scael.Ar file2
2424333Svanand
25*43687Scael.Ar file3 ,
26*43687Scaelwriting the result to the standard output.
27*43687ScaelThe options describe different methods of merging and
28*43687Scaelpurging
29*43687Scaelthe separate versions into a new file.
30*43687Scael.Nm Diff3
31*43687Scaelis used by
32*43687Scael.Xr RCS 1
33*43687Scaelto merge specific versions or create
34*43687Scaelnew versions.
35*43687Scael.Pp
36*43687ScaelOptions are:
37*43687Scael.Tp Fl e
38*43687ScaelProduces output in a form suitable as an input script for the
39*43687Scael.Xr ed 1
40*43687Scaelutility.  The script may then be used to merge differences common
41*43687Scaelbetween all three files and differences specific to file1 and file3.
42*43687ScaelIn other words, the
43*43687Scael.Fl e
44*43687Scaeloption ignores differences specific to file1 and file2, and those
45*43687Scaelspecific to file2 and file3.  It is useful for backing out changes
46*43687Scaelspecific to file2 only.
47*43687Scael.Tp Fl x
48*43687ScaelProduces an output script suitable for
49*43687Scael.Xr ed 1
50*43687Scaelwith changes
51*43687Scaelspecific only to all three versions.
52*43687Scael.Tp Fl 3
53*43687ScaelProduces an output script suitable for
54*43687Scael.Xr ed 1
55*43687Scaelwith changes
56*43687Scaelspecific only to file3.
57*43687Scael.Tp Fl E , X
58*43687ScaelSimilar to
59*43687Scael.Fl e
6024333Svanand
61*43687Scael.Fl x  ,
6224333Svanrespectively, but treat overlapping changes (i.e., changes that would
63*43687Scaelbe noted with ==== in the normal listing) differently.  The overlapping
6424333Svanlines from both files will be inserted by the edit script, bracketed
6524333Svanby "<<<<<<" and ">>>>>>" lines.
66*43687Scael.Tp
67*43687Scael.Pp
68*43687ScaelThe
69*43687Scael.Fl E
70*43687Scaeloption is used by RCS
71*43687Scael.Xr merge  1
72*43687Scaelto insure that overlapping changes in the merged files are preserved
73*43687Scaeland brought to someone's attention.
74*43687Scael.Pp
7524333SvanFor example, suppose lines 7-8 are changed in both file1 and file2.
7624333SvanApplying the edit script generated by the command
77*43687Scael.Pp
78*43687Scael.Dl diff3 -E file1 file2 file3
79*43687Scael.Pp
8024333Svanto file1 results in the file:
81*43687Scael.Ds I
8224333Svanlines 1-6
8324333Svanof file1
8424333Svan<<<<<<< file1
8524333Svanlines 7-8
8624333Svanof file1
8724333Svan=======
8824333Svanlines 7-8
8924333Svanof file3
9024333Svan>>>>>>> file3
9124333Svanrest of file1
92*43687Scael.De
93*43687Scael.Pp
94*43687ScaelThe default output of
95*43687Scael.Nm diff3
96*43687Scaelmakes notation of the differences between all files, and those differences
97*43687Scaelspecific to each pair of files. The
98*43687Scaelchanges are described by
99*43687Scaelthe commands neccessary for
100*43687Scael.Xr ed 1
101*43687Scaelto create the desired target from the different versions.
102*43687ScaelSee
103*43687Scael.Xr diff 1
104*43687Scaelfor a description of the commands.
105*43687Scael.Tw Fl
106*43687Scael.Tp Li \&====
107*43687ScaelThe lines beneath this notation are ranges of lines which are different
108*43687Scaelbetween all files.
109*43687Scael.Tc Li \&====
110*43687Scael.Va n
111*43687Scael.Cx
112*43687ScaelThe lines beneath this notation are ranges of lines which are exclusively
113*43687Scaeldifferent in file
114*43687Scael.Va n .
115*43687Scael.Tp
116*43687Scael.Sh EXAMPLES
117*43687Scael.Pp
118*43687ScaelIf three files were to contain:
119*43687Scael.Ds I
120*43687Scael.Cw  mooxthree mooxthree mooxthree
121*43687Scael.Cl file1	file2	file3
122*43687Scael.Cl moo	moo	moo
123*43687Scael.Cl moo too	moon	moon
124*43687Scael.Cl moo three	moo moo	moo moo
125*43687Scael.Cl tangent	beam	milk
126*43687Scael.Cl moo moo	sun	butter
127*43687Scael.Cl \tcloud	beam
128*43687Scael.Cl \tmoo moo
129*43687Scael.Cl \tmoo moo
130*43687Scael.Cw
131*43687Scael.De
132*43687Scael.Pp
133*43687ScaelThe command line
134*43687Scael.Pp
135*43687Scael.Dl diff3 -e file1 file2 file3
136*43687Scael.Pp
137*43687Scaelproduces the following ed script:
138*43687Scael.Pp
139*43687Scael.Ds C
140*43687Scael====1
141*43687Scael1:2,4c
142*43687Scael  moo two
143*43687Scael  moo three
144*43687Scael  tangent
145*43687Scael2:2c
146*43687Scael3:2c
147*43687Scael  moon
148*43687Scael====
149*43687Scael1:5a
150*43687Scael2:4,8c
151*43687Scael  beam
152*43687Scael  sun
153*43687Scael  cloud
154*43687Scael  moo moo
155*43687Scael  moo moo
156*43687Scael3:4,6c
157*43687Scael  milk
158*43687Scael  butter
159*43687Scael  beam
160*43687Scael.De
161*43687Scael.Sh FILES
162*43687Scael.Dw /usr/bin/diff3
163*43687Scael.Di L
164*43687Scael.Dp Pa /tmp/d3?????
165*43687Scaeltemporary files.
166*43687Scael.Dp Pa /usr/bin/diff3
167*43687Scaelthe executable.
168*43687Scael.Dp
169*43687Scael.Sh SEE ALSO
170*43687Scael.Xr diff 1
171*43687Scael.Xr ed 1
172*43687Scael.Xr rcs 1
173*43687Scael.Sh HISTORY
174*43687Scael.Nm Diff3
175*43687Scaelappeared in Version 7 AT&T Unix.
176*43687Scael.Sh BUGS
17724333SvanThe
178*43687Scael.Fl e
179*43687Scaeloption
180*43687Scaelcannot catch and change
181*43687Scaellines which have
182*43687Scael.Sq Li \&.
183*43687Scaelas the first ans only character on the line.
184*43687ScaelThe resulting script will fail on that line
185*43687Scaelas the
186*43687Scael.Sq Li \&.
187*43687Scaelis an
188*43687Scael.Xr ed 1
189*43687Scaelediting command.
190