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