Node:diff3 Hunks, Next:, Previous:Detailed diff3 Normal, Up:Comparing Three Files



diff3 Hunks

Groups of lines that differ in two or three of the input files are called diff3 hunks, by analogy with diff hunks (see Hunks). If all three input files differ in a diff3 hunk, the hunk is called a three-way hunk; if just two input files differ, it is a two-way hunk.

As with diff, several solutions are possible. When comparing the files A, B, and C, diff3 normally finds diff3 hunks by merging the two-way hunks output by the two commands diff A B and diff A C. This does not necessarily minimize the size of the output, but exceptions should be rare.

For example, suppose F contains the three lines a, b, f, G contains the lines g, b, g, and H contains the lines a, b, h. diff3 F G H might output the following:

====2
1:1c
3:1c
  a
2:1c
  g
====
1:3c
  f
2:3c
  g
3:3c
  h

because it found a two-way hunk containing a in the first and third files and g in the second file, then the single line b common to all three files, then a three-way hunk containing the last line of each file.