zograscope :: zs-diff
zs-diff
is a terminal-based syntax-aware diff. The syntax-aware part means
that comparison isn't sensible to formatting changes and understands general
structure of its input.
The primary purpose of the utility is to be used as external diff within git
.
Complicated changes of expressions or rewrites of functions might produce results that are hard to understand. Small or medium changes should be mostly handled well.
See the manual page for more details.
(This section is outdated and needs an update.)
This section presents various kinds of alternative diffs and demonstrates why syntax-aware ones are useful.
The example was crafted to be small, non-trivial (all tools handle trivial
changes gracefully) and demonstrate all four kinds of changes (deletion,
insertion, update and move). It partially avoids cases which due to current
heuristics don't look that nice in zs-diff
, but is otherwise objective (those
cases are usually less common and aren't actually handled well by other tools
either).
Complete removal and addition isn't bad on its own, but it forces to match lines manually and look for changes in them manually too (diff-highlight script doesn't work in cases like this one).
Somewhat more readable version of git-diff
even though it lacks highlighting.
The alignment is good. Highlighting within lines is somewhat messy.
This is quite readable actually, but again character-level diffing is hard to understand.
The granularity of detected changes is coarse, but changes can be identified.
Disregarding unfortunate colors it's possible to see that structural changes were in fact captured albeit not perfectly.
Fine-grained matching would benefit from improvements as well as change detection for more complicated cases in general, but changes that were applied to this piece of code are quite easy to see and reason about.