data-oriented-programming icon indicating copy to clipboard operation
data-oriented-programming copied to clipboard

wrong condition in threeWayMerge?

Open dilbert-ro opened this issue 2 years ago • 1 comments

https://github.com/viebel/data-oriented-programming/blob/07bf95b4f4bedeb5cd9cdaa04e59b96efdf2727b/src/chapter05/consistency.js#L5

if(havePathInCommon(previousToCurrent, previousToNext)) { return _.merge(current, previousToNext); }

In the book, the explanation for the code above is:

"In order to determine whether there is a conflict, we calculate two diffs: the diff between previous and current and the diff between previous and next. If the intersection between the two diffs is empty, it means there is no conflict. We can safely patch the changes between previous to next into current."

Per my understanding the condition should be negated: if(**!**havePathInCommon(previousToCurrent, previousToNext)) { ...

It seems that the code throws exception if the intersection is empty.

dilbert-ro avatar Dec 04 '23 20:12 dilbert-ro

You are absolutely correct. Could you open a PR?

viebel avatar Dec 05 '23 06:12 viebel

@viebel I ran into the same thing and I've been confused, so I opened a PR for the correction. Would you mind checking this out? Thanks.

  • https://github.com/viebel/data-oriented-programming/pull/20

YukiOta avatar Aug 01 '24 23:08 YukiOta

Thank you. PR merged.

viebel avatar Aug 02 '24 09:08 viebel