2 ms·
The diff algorithm is a bit weird
by plus- 13y ago
The diff algorithm is a bit weird
- gecko 13y agoIt's trying to do word-by-word diffing, since English isn't code, but, unlike Word and other tools that attempt to do that, it doesn't have e.g. cursor movement history to make the editing sane. Thus, that's what you get. This is a similar problem to what you have on other diff programs, by the way. Any sane diff tool will give you an equivalent diff to any other one, and it'll give you an equivalent minimal diff as well, but the human friendliness of the diff varies widely on the algorithms selected. The best tools I've seen use some source awareness to give you a diff that can pick up that e.g. you removed an "if" guard and then unintendented its child block. The worst do a greedy linear scan to make their patches. Most tools I use (especially ones based on a recursive algorithm) are in the middle.