Jump to content

diff3

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 109.118.113.87 (talk) at 17:09, 25 April 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
diff3
Developer(s)AT&T Bell Laboratories
Initial releaseJanuary 1979; 46 years ago (1979-01)
Operating systemUnix and Unix-like
TypeCommand

diff3 is a Unix utility to compare three files and show any differences among them. diff3 can also merge files, implementing a three-way merge.

History and implementations

diff3 originally appeared in Version 7 Unix of 1979. A very similar version was found in Berkeley Software Distribution (BSD) and was inherited into OpenBSD and probably Solaris.[1][2]

On most modern Unix-like systems, even BSD-derived ones like FreeBSD and NetBSD, the diff3 provided is GNU's version in diffutils (formerly GNU Tools). This version has the ability to merge files on its own without relying on ed. It internally invokes diff to do the comparison, but can use any other compatible tool too.[3]

"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 time.

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 overlap.

lines.

References

  1. ^ diff3(1) – OpenBSD General Commands Manual
  2. ^ "diff3 - man pages section 1: User Commands". Solaris 11.3 documentation.
  3. ^ diff3(1) – Linux General Commands Manual

See also