문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top