java-diff-utils icon indicating copy to clipboard operation
java-diff-utils copied to clipboard

3-way merge - correct output of CONFLICT_PRODUCES_MERGE_CONFLICT

Open msevcenko opened this issue 4 years ago • 2 comments

Describe the bug I suspect CONFLICT_PRODUCES_MERGE_CONFLICT does not produce correct output.

To Reproduce Steps to reproduce the behavior:

  1. Example data BASE Imagine there's no heaven LEFT Imagine there's no HEAVEN RIGHT IMAGINE there's no heaven
  2. Sample code
Patch<String> rightPatch = diff(split(base), split(right))
		.withConflictOutput(CONFLICT_PRODUCES_MERGE_CONFLICT );
		
List<String> applied = rightPatch.applyTo(split(left));

return Joiner.on("\r\n").join(applied)

Expected behavior

<<<<<< HEAD
Imagine there's no HEAVEN
======
IMAGINE there's no heaven
>>>>>>> PATCH

Actual behavior

<<<<<< HEAD
Imagine there's no HEAVEN
======
Imagine there's no heaven
>>>>>>> PATCH

That is, it seems that the other part of the conflict, it displays the base, instead of the second downstream, version.

msevcenko avatar Dec 10 '21 17:12 msevcenko

Introduced your test but could not reproduce your behaviour.

Since there is no context specified, my test successfully can apply this patch to the left text and it results in:

IMAGINE there's no HEAVEN

wumpz avatar May 13 '22 22:05 wumpz

Doesn't it process the input line by line? To merge this conflict, you would need to process the line word-wise? Because line-wise, it clearly is a conflict, isnt't it?

msevcenko avatar May 16 '22 05:05 msevcenko

Stale issue message

github-actions[bot] avatar Jan 05 '23 02:01 github-actions[bot]