Merge that works at word granularity instead of line

diff()patchsoftware-rectext processing

The old diff, patch, and merge programs, and their modern descendents in the form of version control systems work great for managing source code that can be edited concurrently by multiple people.

They are, however, strictly line oriented, and thus tend to fall down flat on text that is more free form. In my particular case, I'm working with latex files edited by multiple people, and text is constantly reflowed — adding or subtracting a word to a paragraph alters the line boundaries for the rest of the paragraph. There are diff tools that highlight changes within a line (many modern GUI ones), or even handle reflowed text (wdiff, git diff --word-diff). However, I've found nothing that handles three-way-merges or patching.

Does anyone know of a good tool that will do this automatically? (Yes, I could chop the text up so as to put each word (and run of white space) onto a separate line. Something like the format for git diff --word-diff=porcelain might not be a bad choice. But making this reversible and robust to an automated merge (including merge conflict markers) is not quite trivial).

Bonus points for a git merge driver.

Best Answer

Wiggle (git://neil.brown.name/wiggle) can do this, and has a Debian package

Related Question