I would like to produce a file consisting of the three-way diff of three files, with every difference represented as a conflict in the git style. That is, common lines are shown verbatim, and differing sections of a file are shown with conflict markers "<<<<<<", "||||||", "======", and ">>>>>>" (also called "conflict brackets"):
common line 1
common line 2
<<<<<<<
text from mine.txt
|||||||
text from base.txt
more text from base.txt
=======
text from yours.txt
>>>>>>>
common line 3
common line 4
<<<<<<<
same text in mine.txt and yours.txt, none in base.txt
|||||||
=======
same text in mine.txt and yours.txt, none in base.txt
>>>>>>>
common line 5
common line 6
I would like every difference to be marked with conflict brackets, including differences that are mergeable. And I would like to obtain the output without human intervention.
Here are some options that do not work:
git diffonly takes two files as input; that is, it compares two things rather than three.git merge-filedoes not show mergeable differences (it merges them).diff3 -mis likegit merge-file: close: it shows the whole file, with conflict markers for conflicts, but it does not show conflict markers for mergeable differences.diff3shows all the differences, even mergeable ones, but not in the given format.diff3 -Adoes not show all the differences, and mergeable ones are not output with conflict markers.
I can write a program that takes the diff3 output and the original files, and outputs the conflicted file in git style. However, I would prefer to avoid that if I can.
Git's
vimdiffmergetool shows you all four versions (ours, base, theirs, results-so-far), you can step through the changes, including all the automerged ones, with]cand[cand see everything,1doto take the local version,2doto take the base version,3doto take the remote version.