Next: , Previous: , Up: diff3 Merging   [Contents][Index]


8.2 Marking Conflicts

diff3 can mark conflicts in the merged output by bracketing them with special marker lines. A conflict that comes from two files A and B is marked as follows:

<<<<<<< A
lines from A
=======
lines from B
>>>>>>> B

A conflict that comes from three files A, B and C is marked as follows:

<<<<<<< A
lines from A
||||||| B
lines from B
=======
lines from C
>>>>>>> C

The --show-all (-A) option acts like the -e option, except that it brackets conflicts, and it outputs all changes from older to yours, not just the unmerged changes. Thus, given the sample input files (see Sample diff3 Input), ‘diff3 -A lao tzu tao’ puts brackets around the conflict where only tzu differs:

<<<<<<< tzu
=======
The Way that can be told of is not the eternal Way;
The name that can be named is not the eternal name.
>>>>>>> tao

And it outputs the three-way conflict as follows:

<<<<<<< lao
||||||| tzu
They both may be called deep and profound.
Deeper and more profound,
The door of all subtleties!
=======

  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
>>>>>>> tao

The --show-overlap (-E) option outputs less information than the --show-all (-A) option, because it outputs only unmerged changes, and it never outputs the contents of the second file. Thus the -E option acts like the -e option, except that it brackets the first and third files from three-way overlapping changes. Similarly, -X acts like -x, except it brackets all its (necessarily overlapping) changes. For example, for the three-way overlapping change above, the -E and -X options output the following:

<<<<<<< lao
=======

  -- The Way of Lao-Tzu, tr. Wing-tsit Chan
>>>>>>> tao

If you are comparing files that have meaningless or uninformative names, you can use the --label=label option to show alternate names in the ‘<<<<<<<’, ‘|||||||’ and ‘>>>>>>>’ brackets. This option can be given up to three times, once for each input file. Thus ‘diff3 -A --label X --label Y --label Z A B C’ acts like ‘diff3 -A A B C’, except that the output looks like it came from files named ‘X’, ‘Y’ and ‘Z’ rather than from files named ‘A’, ‘B’ and ‘C’.


Next: , Previous: , Up: diff3 Merging   [Contents][Index]