Expand description
fc-git — working-tree summary for the git surface.
§What is here, and why only this
The git surface renders a working tree: branch, status counts, a file list, per-file line stats. Almost none of that is computation — it is DOM. What is computation is the part worth getting exactly right, and this crate holds it:
-
summarize_status— folding entries into staged/unstaged/conflicted/ untracked counts. -
order_entries— putting the entries that need attention first. -
diff_counts— added/removed line totals for a file.
§The rule that shapes the boundary
No js-sys. Linking it costs ~302 KB the moment any of it is used, and
LTO cannot remove it (AGENTS.md). So nothing here returns Vec<JsValue> or
js_sys::Array. Everything crosses as a small number of primitives or a flat
typed array, and the caller holds the actual strings.
diff_counts takes the two texts as arguments and returns two numbers, rather
than returning a Vec<DiffLine> the caller would have to walk back over the
boundary — a range crosses as two numbers, never as an array of objects.
§Offsets are UTF-16 code units
Line splitting here matches fc-diff and the JS twin: a line ends at \n, and
counts are of lines, not bytes. Nothing here produces an offset, so the
surrogate-pair concern that fc-diff handles does not arise; the rule is
recorded because it is the same boundary and a future change must not quietly
diverge.
Structs§
Enums§
- State
- Where a file is in its lifecycle. Matches the JS
IndexState.
Functions§
- diff_
counts - Counts added and removed lines between two file revisions.
- diff_
counts_ js - Counts added and removed lines. Returns a flat
[added, removed]. - order_
entries - Returns indices into
entries, ordered by attention rank then by path. - order_
entries_ js - Returns indices ordered by attention then path. Returns indices ordered by attention rank, then by the caller’s existing order.
- summarize_
status - Folds entries into header counts.
- summarize_
status_ js - Folds entries into counts.