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 3AaEeiTXx 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 T, Fl Fl initial-tab 121In the normal listing, 122use a tab instead of two spaces 123at the beginning of each line. 124In modes that produce an 125.Xr ed 1 126script, this option changes nothing. 127.It Fl x, Fl Fl overlap-only 128Produces an output script suitable for 129.Xr ed 1 130with changes 131specific only to all three versions. 132.It Fl Fl diff-program Ar program 133Use 134.Ar program 135instead of the default 136.Xr diff 1 137to compare files. 138.It Fl Fl strip-trailing-cr 139Strip trailing carriage return on input files. 140.El 141.Pp 142The 143.Fl E 144option is used by 145.Tn RCS 146.Xr merge 1 147to ensure that overlapping changes in the merged files are preserved 148and brought to someone's attention. 149.Pp 150For example, suppose lines 7-8 are changed in both 151.Ar file1 152and 153.Ar file2 . 154Applying the edit script generated by the command 155.Pp 156.Dl $ diff3 -E file1 file2 file3 157.Pp 158to 159.Ar file1 160results in the file: 161.Bd -literal -offset indent 162lines 1-6 163of file1 164<<<<<<< file1 165lines 7-8 166of file1 167======= 168lines 7-8 169of file3 170>>>>>>> file3 171rest of file1 172.Ed 173.Pp 174The default output of 175.Nm 176makes notation of the differences between all files, and those 177differences specific to each pair of files. 178The changes are described by the commands necessary for 179.Xr ed 1 180to create the desired target from the different versions. 181See 182.Xr diff 1 183for a description of the commands. 184.Bl -tag -width "=====" 185.It Li \&==== 186The lines beneath this notation are ranges of lines which are different 187between all files. 188.It \&==== Ns Va n 189The lines beneath this notation are ranges of lines which are exclusively 190different in file 191.Va n . 192.El 193.Sh SEE ALSO 194.Xr diff 1 , 195.Xr ed 1 , 196.Xr merge 1 , 197.Xr rcs 1 , 198.Xr sdiff 1 199.Sh HISTORY 200A 201.Nm 202command appeared in 203.At v7 . 204.Sh BUGS 205The 206.Fl e 207option cannot catch and change lines which have 208.Ql \&. 209as the first and only character on the line. 210The resulting script will fail on that line 211as 212.Ql \&. 213is an 214.Xr ed 1 215editing command. 216