Split a file with conflict markers
-
27-05-2021 - |
Question
I am looking for a tool that will split a file that has conflict markers into the two separate files. Is there anything out there that does this already?
Solution
xxdiff can do that:
xxdiff --unmerge myfile.txt
it also works if the conflict markers result from a 3-way diff
xxdiff --unmerge3 myfile.txt
OTHER TIPS
The tool I work for (ECMerge) does that, primarily with the target of helping you to merge them visually of course. You could as well save the left/right/ancestor files with the built-in Javascript engine. ECMerge reads markers for most 'well-known' source code controls (CVS, git, mercurial, bazaar, SubVersion, Perforce, those compatible with the previously cited and of course its own markers!).
Winmerge does that, they call it "Resolve conflict files". It only works on Windows though.
As requested, my own solution to my question was to create the following Perl script.