Assume that files MINE and YOURS are descendants of OLD.
FILE_MINE=
abc def ghi
FILE_OLD=
abc jkl ghi
FILE_YOURS=
abc def ghi
Command diff3 -m MIND OLD YOURS
gives:
abc <<<<<<< OLD jkl ======= def >>>>>>> YOURS ghi
diff3 cannot resolve that MINE and YOURS made identical changes.
Why? And, is there a way to resolve this issue?
Tickle your brain with this:
diff OLD MIND
and diff OLD YOURS
have identical hunks in their output.
2c2 < jkl --- > def
Should these hunks not "cancel-out" during the three-way merge?
What did you expect to have?
As the article describing diff3 utility says:
... This (merging) fails to be true when all three input files differ or when only older differs; we call this a conflict. When all three input files differ, we call the conflict an overlap
Therefore, the case you've described is treated as a conflict. 'Why so?' you might ask. Because of the diff3 algorithm. Description you can find at the same page:
You can think of this (merging) as subtracting older from yours and adding the result to mine, or as merging into mine the changes that would turn older into yours
It cannot resolve differences properly because it does not have a proper context of changes being made.
I would agree with you if you're going to say that it should work using some other approach. But... it is what it is. diff3 is not perfect, I would recommend using other tools if you want to do it right as described in the article
来源:https://stackoverflow.com/questions/3931490/gnu-diff3-three-way-merge-gives-unexpected-result