HOME

TheInfoList



OR:

diff3 is a
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
utility to compare three files and show any differences among them. diff3 can also
merge Merge, merging, or merger may refer to: Concepts * Merge (traffic), the reduction of the number of lanes on a road * Merge (linguistics), a basic syntactic operation in generative syntax in the Minimalist Program * Merger (politics), the comb ...
files, implementing a
three-way merge In version control, merging (also called integration) is a fundamental operation that reconciles multiple changes made to a version-controlled collection of files. Most often, it is necessary when a file is modified on two independent branches an ...
.


History and implementations

originally appeared in
Version 7 Unix Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercial ...
of 1979. A very similar version was found in Berkeley Software Distribution (BSD) and was inherited into OpenBSD and probably Solaris. On most modern Unix-like systems, even BSD-derived ones like FreeBSD and NetBSD, the diff3 provided is
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
's version in diffutils (formerly ''GNU Tools''). This version has the ability to merge files on its own without relying on . It internally invokes to do the comparison, but can use any other compatible tool too. The command is available as a separate package for Microsoft Windows as part of the
UnxUtils UnxUtils is a collection of ports of common GNU Unix-like utilities to native Win32, with executables only depending on the Microsoft C- runtime msvcrt.dll. The collection was last updated externally on April 15, 2003, by Karl M. Syring. The mo ...
collection of
native Native may refer to: People * Jus soli, citizenship by right of birth * Indigenous peoples, peoples with a set of specific rights based on their historical ties to a particular territory ** Native Americans (disambiguation) In arts and entert ...
Win32 The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations th ...
ports A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as H ...
of common GNU Unix-like utilities. "Diff3" has also become a generic name for the three-way-merge algorithm, specifically one based on reconciling two different diffs stemming from the first source.


Merging from a common ancestor

When two people have made changes to copies of the same file, diff3 can produce a merged output that contains both sets of changes together with warnings about conflicts. diff3 can merge three or more sets of changes to a file by merging two change sets at a time. diff3 can incorporate changes from two modified versions into a common preceding version. This enables users to merge the sets of changes represented by the two newer files. This can be enabled using a command like this: diff3 mine older yours. This is like subtracting the file older from the file yours and adding the result to the file mine, or as merging into mine the changes that would turn older into yours. This merging is well-defined as long as mine and older match in the neighborhood of each such change. This fails to be true when all three input files differ or when only older differs; this is a conflict. When all three input files differ, the conflict is an overlap. diff3 has several methods to handle overlaps and conflicts. It can omit overlaps or conflicts, or select only overlaps, or mark conflicts with special <<<<<<< and >>>>>>> lines. diff3 can output the
merge Merge, merging, or merger may refer to: Concepts * Merge (traffic), the reduction of the number of lanes on a road * Merge (linguistics), a basic syntactic operation in generative syntax in the Minimalist Program * Merger (politics), the comb ...
results as an ed script that can be applied to the first file to yield the merged output. However, directly generating the merged output bypasses some problems with ed.


See also

*
diff In computing, the utility diff is a data comparison tool that computes and displays the differences between the contents of files. Unlike edit distance notions used for other purposes, diff is line-oriented rather than character-oriented, but ...


References

{{reflist


External links


A formal investigation of Diff3
* GNU diffutils manual

an

Free file comparison tools