How to replace duplicated multi-line groups, e.g. from git & diff3
0
votes
2
answers
58
views
I'm rebasing legacy code, and finding lots of conflicts caused by scripts -- usually code formatters. The changes are simple and predictable, so I can trivially re-run the script to apply the changes to the code -- which usually leaves me with three identical "snippets" surrounded by git's diff markers.
How can I write a script to find three matching snippets, with their diff markers, and convert them to a single snippet?
Example:
git rebase
produces this:
>>>>>> 0cfd85b8e3... Beautify.
Re-running the formatter gives this:
>>>>>> 0cfd85b8e3... Beautify.
which I would like to convert to this:
ACC
BCC
I've tried many, many things including grep (it struggles with new-lines) and pcregrep (I struggle with back-references/capture-groups). Any ideas?
Asked by Steve Almond
(176 rep)
Mar 28, 2021, 10:01 AM
Last activity: Aug 20, 2021, 12:24 AM
Last activity: Aug 20, 2021, 12:24 AM