Skip to main content

Module diff

Module diff 

Source
Expand description

The tree diff Refs.Diff serves (the event stream).

Until this module existed the RPC answered:

Refs.Diff: the server has no tree-diff engine; gix’s blob-diff is client-side porcelain and an S crate must not link it

The second half of that sentence is still true and is why this file is here rather than a dependency line. What it got wrong was the conclusion: a tree diff is not blob porcelain. It is a walk over two trees, and the only thing it needs from a repository is GitServe::read — which every engine has, which the appliance already links, and which costs no crate.

§What it computes, and what it does not

  • Structure, exactly: which paths were added, deleted, modified or changed type, with both object ids and both raw modes. This is what a change proposal is built on and it is never approximated.
  • Line counts, exactly, by way of [edit_counts] — a bounded Myers walk. Where the bound is hit the answer is a genuine upper bound (every old line deleted, every new line inserted) and never a zero: a 0/0 on a file that changed is the shape of “we did not look”, and it is indistinguishable from “nothing happened” to whoever reads it.
  • No rename detection. RENAMED and COPIED exist in the proto and are never emitted: a rename is a heuristic over content similarity, and inventing one here would make the answer depend on a threshold nobody chose. A rename is reported the way git diff without -M reports it — one DELETED and one ADDED — which is the truth about the trees.

Enums§

DiffError
Everything that went wrong reading a repository during a diff.
Op
One step of an edit script, in old-file order.

Functions§

compare
Compare two trees and report every path that differs.
diff_ops
The full edit script, not just its length.
split_lines
Split a blob into lines, for callers outside this module.
trace_line
Where line new_line of the new file came from in the old one, if it was already there.