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 April 19, 2022 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 3AaEeimTXx 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 show-all 75Output all changes, bracketing conflicts. 76.It Fl a , Fl Fl text 77Treat all files as ASCII. 78.It Fl E , Fl Fl show-overlap 79.It Fl X 80Similar to 81.Fl e 82and 83.Fl x , 84respectively, but treat overlapping changes (i.e., changes that would 85be noted with ==== in the normal listing) differently. 86The overlapping lines from both files will be inserted by the edit script, 87bracketed by "<<<<<<" and ">>>>>>" lines. 88.It Fl e , Fl Fl ed 89Produces output in a form suitable as an input script for the 90.Xr ed 1 91utility. 92The script may then be used to merge differences common between all 93three files and differences specific to 94.Ar file1 95and 96.Ar file3 . 97In other words, the 98.Fl e 99option ignores differences specific to 100.Ar file1 101and 102.Ar file2 , 103and those specific to 104.Ar file2 105and 106.Ar file3 . 107It is useful for backing out changes specific to 108.Ar file2 109only. 110.It Fl i 111Appends 'w' and 'q' 112.Xr ed 1 113commands. 114.It Fl L , Fl Fl label 115Defines labels to print instead of file names 116.Ar file1 , 117.Ar file2 118and 119.Ar file3 . 120.It Fl m, Fl Fl merge 121Merge output instead of generating ed script. 122.It Fl T, Fl Fl initial-tab 123In the normal listing, 124use a tab instead of two spaces 125at the beginning of each line. 126In modes that produce an 127.Xr ed 1 128script, this option changes nothing. 129.It Fl x, Fl Fl overlap-only 130Produces an output script suitable for 131.Xr ed 1 132with changes 133specific only to all three versions. 134.It Fl Fl diff-program Ar program 135Use 136.Ar program 137instead of the default 138.Xr diff 1 139to compare files. 140.It Fl Fl strip-trailing-cr 141Strip trailing carriage return on input files. 142.El 143.Pp 144The 145.Fl E 146option is used by 147.Tn RCS 148.Xr merge 1 149to ensure that overlapping changes in the merged files are preserved 150and brought to someone's attention. 151.Pp 152For example, suppose lines 7-8 are changed in both 153.Ar file1 154and 155.Ar file2 . 156Applying the edit script generated by the command 157.Pp 158.Dl $ diff3 -E file1 file2 file3 159.Pp 160to 161.Ar file1 162results in the file: 163.Bd -literal -offset indent 164lines 1-6 165of file1 166<<<<<<< file1 167lines 7-8 168of file1 169======= 170lines 7-8 171of file3 172>>>>>>> file3 173rest of file1 174.Ed 175.Pp 176The default output of 177.Nm 178makes notation of the differences between all files, and those 179differences specific to each pair of files. 180The changes are described by the commands necessary for 181.Xr ed 1 182to create the desired target from the different versions. 183See 184.Xr diff 1 185for a description of the commands. 186.Bl -tag -width "=====" 187.It Li \&==== 188The lines beneath this notation are ranges of lines which are different 189between all files. 190.It \&==== Ns Va n 191The lines beneath this notation are ranges of lines which are exclusively 192different in file 193.Va n . 194.El 195.Sh SEE ALSO 196.Xr diff 1 , 197.Xr ed 1 , 198.Xr merge 1 , 199.Xr rcs 1 , 200.Xr sdiff 1 201.Sh HISTORY 202A 203.Nm 204command appeared in 205.At v7 . 206.Sh BUGS 207The 208.Fl e 209option cannot catch and change lines which have 210.Ql \&. 211as the first and only character on the line. 212The resulting script will fail on that line 213as 214.Ql \&. 215is an 216.Xr ed 1 217editing command. 218