summaryrefslogtreecommitdiff
path: root/usr.bin/diff3/diff3.1
blob: 1afbea905bad8d1d7181fd2c874b871498769dfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
.\" $OpenBSD: diff3.1,v 1.3 2003/10/24 08:01:52 jmc Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.\"	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. 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.
.\"
.\"     @(#)diff3.1	8.2 (Berkeley) 4/18/94
.\"
.Dd April 18, 1994
.Dt DIFF3 1
.Os
.Sh NAME
.Nm diff3
.Nd 3-way differential file comparison
.Sh SYNOPSIS
.Nm diff3
.Op Fl aexEX3
.Ar file1 file2 file3
.Sh DESCRIPTION
The
.Nm
utility compares the contents of three different versions of a file,
.Ar file1 ,
.Ar file2
and
.Ar file3 ,
writing the result to the standard output.
The options describe different methods of merging and
purging
the separate versions into a new file.
.Nm
is used by
.Xr rcs 1
to merge specific versions or create
new versions.
.Pp
The options are as follows:
.Bl -tag -width "-E, -X"
.It Fl a
Treat all files as ASCII.
.It Fl e
Produces output in a form suitable as an input script for the
.Xr ed 1
utility.
The script may then be used to merge differences common between all
three files and differences specific to
.Ar file1
and
.Ar file3 .
In other words, the
.Fl e
option ignores differences specific to
.Ar file1
and
.Ar file2 ,
and those specific to
.Ar file2
and
.Ar file3 .
It is useful for backing out changes specific to
.Ar file2
only.
.It Fl x
Produces an output script suitable for
.Xr ed 1
with changes
specific only to all three versions.
.It Fl 3
Produces an output script suitable for
.Xr ed 1
with changes
specific only to
.Ar file3 .
.It Fl E , X
Similar to
.Fl e
and
.Fl x ,
respectively, but treat overlapping changes (i.e., changes that would
be noted with ==== in the normal listing) differently.
The overlapping lines from both files will be inserted by the edit script,
bracketed by "<<<<<<" and ">>>>>>" lines.
.El
.Pp
The
.Fl E
option is used by
.Tn RCS
.Xr merge 1
to ensure that overlapping changes in the merged files are preserved
and brought to someone's attention.
.Pp
For example, suppose lines 7-8 are changed in both
.Ar file1
and
.Ar file2 .
Applying the edit script generated by the command
.Pp
.Dl diff3 -E file1 file2 file3
.Pp
to
.Ar file1
results in the file:
.Bd -literal -offset indent
lines 1-6
of file1
<<<<<<< file1
lines 7-8
of file1
=======
lines 7-8
of file3
>>>>>>> file3
rest of file1
.Ed
.Pp
The default output of
.Nm
makes notation of the differences between all files, and those
differences specific to each pair of files.
The changes are described by the commands necessary for
.Xr ed 1
to create the desired target from the different versions.
See
.Xr diff 1
for a description of the commands.
.Bl -tag -width "====="
.It Li \&====
The lines beneath this notation are ranges of lines which are different
between all files.
.It \&==== Ns Va n
The lines beneath this notation are ranges of lines which are exclusively
different in file
.Va n .
.El
.Sh ENVIRONMENT
.Bl -tag -width TMPDIR
.It Ev TMPDIR
If the environment variable
.Ev TMPDIR
exists,
.Nm
will use the directory specified by
.Ev TMPDIR
as the temporary directory.
.El
.Sh FILES
.Bl -tag -width /usr/libexec/diff3prog -compact
.It Pa /tmp/d3a.XXXXXXXXXX
temporary file
.It Pa /tmp/d3b.XXXXXXXXXX
temporary file
.It Pa /usr/libexec/diff3
the actual executable
.El
.Sh SEE ALSO
.Xr diff 1 ,
.Xr ed 1 ,
.Xr merge 1 ,
.Xr rcs 1
.Sh HISTORY
A
.Nm
command appeared in
.At v7 .
.Sh BUGS
The
.Fl e
option cannot catch and change lines which have
.Ql \&.
as the first and only character on the line.
The resulting script will fail on that line
as
.Ql \&.
is an
.Xr ed 1
editing command.