Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3-way merge #181

Open
uiteoi opened this issue Jun 5, 2017 · 5 comments
Open

3-way merge #181

uiteoi opened this issue Jun 5, 2017 · 5 comments

Comments

@uiteoi
Copy link

uiteoi commented Jun 5, 2017

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.

@gonzofish
Copy link

This was implemented but not made part of the top-level API f94da90

@goodmind
Copy link

goodmind commented Feb 7, 2019

@gonzofish how to write it to file like git does?

@gonzofish
Copy link

sorry @goodmind, I don't remember, I haven't used this library in over a year...sorry I cannot be more help

@goodmind
Copy link

goodmind commented Feb 7, 2019

@kpdecker

@doug65536
Copy link

doug65536 commented Jan 25, 2022

I have done it, but I found merge misbehaving bug Basically what I did was hand-process the "+", "-" " " prefix of the lines that result from calling merge, and handle the conflict blocks that look like { conflict: true, mine: ['#yes'], theirs: ['#no']} interspersed into the string lines of the patch. You write >>>>>>>> (emit the 'theirs' lines) ======== (emit 'ours' lines) <<<<<<<<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants