1*9490d37cSjmc.\" $OpenBSD: diff3.1,v 1.7 2007/05/31 19:20:09 jmc Exp $ 2d407ca27Smillert.\" 3d407ca27Smillert.\" Copyright (c) 1990, 1993, 1994 4d407ca27Smillert.\" The Regents of the University of California. All rights reserved. 5d407ca27Smillert.\" 6d407ca27Smillert.\" Redistribution and use in source and binary forms, with or without 7d407ca27Smillert.\" modification, are permitted provided that the following conditions 8d407ca27Smillert.\" are met: 9d407ca27Smillert.\" 1. Redistributions of source code must retain the above copyright 10d407ca27Smillert.\" notice, this list of conditions and the following disclaimer. 11d407ca27Smillert.\" 2. Redistributions in binary form must reproduce the above copyright 12d407ca27Smillert.\" notice, this list of conditions and the following disclaimer in the 13d407ca27Smillert.\" documentation and/or other materials provided with the distribution. 14d407ca27Smillert.\" 3. Neither the name of the University nor the names of its contributors 15d407ca27Smillert.\" may be used to endorse or promote products derived from this software 16d407ca27Smillert.\" without specific prior written permission. 17d407ca27Smillert.\" 18d407ca27Smillert.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19d407ca27Smillert.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20d407ca27Smillert.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21d407ca27Smillert.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22d407ca27Smillert.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23d407ca27Smillert.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24d407ca27Smillert.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25d407ca27Smillert.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26d407ca27Smillert.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27d407ca27Smillert.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28d407ca27Smillert.\" SUCH DAMAGE. 29d407ca27Smillert.\" 30d407ca27Smillert.\" @(#)diff3.1 8.2 (Berkeley) 4/18/94 31d407ca27Smillert.\" 32*9490d37cSjmc.Dd $Mdocdate: May 31 2007 $ 33d407ca27Smillert.Dt DIFF3 1 34d407ca27Smillert.Os 35d407ca27Smillert.Sh NAME 36d407ca27Smillert.Nm diff3 37d407ca27Smillert.Nd 3-way differential file comparison 38d407ca27Smillert.Sh SYNOPSIS 39d407ca27Smillert.Nm diff3 4087c98d9cSjmc.Op Fl 3aEeXx 41d407ca27Smillert.Ar file1 file2 file3 42d407ca27Smillert.Sh DESCRIPTION 43d407ca27SmillertThe 44d407ca27Smillert.Nm 45d407ca27Smillertutility compares the contents of three different versions of a file, 46d407ca27Smillert.Ar file1 , 47d407ca27Smillert.Ar file2 48d407ca27Smillertand 49d407ca27Smillert.Ar file3 , 50d407ca27Smillertwriting the result to the standard output. 51d407ca27SmillertThe options describe different methods of merging and 52d407ca27Smillertpurging 53d407ca27Smillertthe separate versions into a new file. 54d407ca27Smillert.Nm 55d407ca27Smillertis used by 56178f0461Sjmc.Xr rcs 1 57d407ca27Smillertto merge specific versions or create 58d407ca27Smillertnew versions. 59d407ca27Smillert.Pp 60d407ca27SmillertThe options are as follows: 61d407ca27Smillert.Bl -tag -width "-E, -X" 6287c98d9cSjmc.It Fl 3 6387c98d9cSjmcProduces an output script suitable for 6487c98d9cSjmc.Xr ed 1 6587c98d9cSjmcwith changes 6687c98d9cSjmcspecific only to 6787c98d9cSjmc.Ar file3 . 68d407ca27Smillert.It Fl a 69d407ca27SmillertTreat all files as ASCII. 7087c98d9cSjmc.It Fl E , X 7187c98d9cSjmcSimilar to 7287c98d9cSjmc.Fl e 7387c98d9cSjmcand 7487c98d9cSjmc.Fl x , 7587c98d9cSjmcrespectively, but treat overlapping changes (i.e., changes that would 7687c98d9cSjmcbe noted with ==== in the normal listing) differently. 7787c98d9cSjmcThe overlapping lines from both files will be inserted by the edit script, 7887c98d9cSjmcbracketed by "<<<<<<" and ">>>>>>" lines. 79d407ca27Smillert.It Fl e 80d407ca27SmillertProduces output in a form suitable as an input script for the 81d407ca27Smillert.Xr ed 1 82d407ca27Smillertutility. 83d407ca27SmillertThe script may then be used to merge differences common between all 84d407ca27Smillertthree files and differences specific to 85d407ca27Smillert.Ar file1 86d407ca27Smillertand 87d407ca27Smillert.Ar file3 . 88d407ca27SmillertIn other words, the 89d407ca27Smillert.Fl e 90d407ca27Smillertoption ignores differences specific to 91d407ca27Smillert.Ar file1 92d407ca27Smillertand 93d407ca27Smillert.Ar file2 , 94d407ca27Smillertand those specific to 95d407ca27Smillert.Ar file2 96d407ca27Smillertand 97d407ca27Smillert.Ar file3 . 98d407ca27SmillertIt is useful for backing out changes specific to 99d407ca27Smillert.Ar file2 100d407ca27Smillertonly. 101d407ca27Smillert.It Fl x 102d407ca27SmillertProduces an output script suitable for 103d407ca27Smillert.Xr ed 1 104d407ca27Smillertwith changes 105d407ca27Smillertspecific only to all three versions. 106d407ca27Smillert.El 107d407ca27Smillert.Pp 108d407ca27SmillertThe 109d407ca27Smillert.Fl E 110d407ca27Smillertoption is used by 111d407ca27Smillert.Tn RCS 112d407ca27Smillert.Xr merge 1 113d407ca27Smillertto ensure that overlapping changes in the merged files are preserved 114d407ca27Smillertand brought to someone's attention. 115d407ca27Smillert.Pp 116d407ca27SmillertFor example, suppose lines 7-8 are changed in both 117d407ca27Smillert.Ar file1 118d407ca27Smillertand 119d407ca27Smillert.Ar file2 . 120d407ca27SmillertApplying the edit script generated by the command 121d407ca27Smillert.Pp 122fb67d519Sjaredy.Dl $ diff3 -E file1 file2 file3 123d407ca27Smillert.Pp 124d407ca27Smillertto 125d407ca27Smillert.Ar file1 126d407ca27Smillertresults in the file: 127178f0461Sjmc.Bd -literal -offset indent 128d407ca27Smillertlines 1-6 129d407ca27Smillertof file1 130d407ca27Smillert<<<<<<< file1 131d407ca27Smillertlines 7-8 132d407ca27Smillertof file1 133d407ca27Smillert======= 134d407ca27Smillertlines 7-8 135d407ca27Smillertof file3 136d407ca27Smillert>>>>>>> file3 137d407ca27Smillertrest of file1 138d407ca27Smillert.Ed 139d407ca27Smillert.Pp 140d407ca27SmillertThe default output of 141d407ca27Smillert.Nm 142d407ca27Smillertmakes notation of the differences between all files, and those 143d407ca27Smillertdifferences specific to each pair of files. 144d407ca27SmillertThe changes are described by the commands necessary for 145d407ca27Smillert.Xr ed 1 146d407ca27Smillertto create the desired target from the different versions. 147d407ca27SmillertSee 148d407ca27Smillert.Xr diff 1 149d407ca27Smillertfor a description of the commands. 150d407ca27Smillert.Bl -tag -width "=====" 151d407ca27Smillert.It Li \&==== 152d407ca27SmillertThe lines beneath this notation are ranges of lines which are different 153d407ca27Smillertbetween all files. 154d407ca27Smillert.It \&==== Ns Va n 155d407ca27SmillertThe lines beneath this notation are ranges of lines which are exclusively 156d407ca27Smillertdifferent in file 157d407ca27Smillert.Va n . 158d407ca27Smillert.El 159d407ca27Smillert.Sh ENVIRONMENT 160d407ca27Smillert.Bl -tag -width TMPDIR 161d407ca27Smillert.It Ev TMPDIR 162d407ca27SmillertIf the environment variable 163d407ca27Smillert.Ev TMPDIR 164d407ca27Smillertexists, 165d407ca27Smillert.Nm 166d407ca27Smillertwill use the directory specified by 167d407ca27Smillert.Ev TMPDIR 168d407ca27Smillertas the temporary directory. 169d407ca27Smillert.El 170d407ca27Smillert.Sh FILES 171d407ca27Smillert.Bl -tag -width /usr/libexec/diff3prog -compact 172d407ca27Smillert.It Pa /tmp/d3a.XXXXXXXXXX 173d407ca27Smillerttemporary file 174d407ca27Smillert.It Pa /tmp/d3b.XXXXXXXXXX 175d407ca27Smillerttemporary file 176fb67d519Sjaredy.It Pa /usr/libexec/diff3prog 177d407ca27Smillertthe actual executable 178d407ca27Smillert.El 179d407ca27Smillert.Sh SEE ALSO 180d407ca27Smillert.Xr diff 1 , 181d407ca27Smillert.Xr ed 1 , 182178f0461Sjmc.Xr merge 1 , 1830cc6cb6eSjmc.Xr rcs 1 , 1840cc6cb6eSjmc.Xr sdiff 1 185178f0461Sjmc.Sh HISTORY 186178f0461SjmcA 187178f0461Sjmc.Nm 188178f0461Sjmccommand appeared in 189178f0461Sjmc.At v7 . 190d407ca27Smillert.Sh BUGS 191d407ca27SmillertThe 192d407ca27Smillert.Fl e 193d407ca27Smillertoption cannot catch and change lines which have 194d407ca27Smillert.Ql \&. 195d407ca27Smillertas the first and only character on the line. 196d407ca27SmillertThe resulting script will fail on that line 197d407ca27Smillertas 198d407ca27Smillert.Ql \&. 199d407ca27Smillertis an 200d407ca27Smillert.Xr ed 1 201d407ca27Smillertediting command. 202