3-way merge
Author: uiteoiCreated Jun 5, 2017Updated Mar 17, 2025
Labelsmerge
This is a feature request.
Given a common ancestor and 2 sets of patches, provide a merged document that may include conflicts to resolve manually.
This would be useful to allow two or more users collaborate on the edition of a document, implementing an equivalent of git merge.
It is assumed that the most recent common ancestor is know and provided as a parameter:
JsDiff.merge( commonAncestor, x_patches, y_patches [, options] )Where x_patches and y_patches are Arrays of patches for the x and y branches from the common ancestor,
Options may be used to provide a manual merge patterns which could default to:
mergePattern: [ "<<<<<<< x", "=======", ">>>>>>> y" ]For the algorithm, see https://www.quora.com/How-does-Git-merge-work.
Source: kpdecker/jsdiff