Skip to main content

Crate fc_git

Crate fc_git 

Source
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:

  1. summarize_status — folding entries into staged/unstaged/conflicted/ untracked counts.

  2. order_entries — putting the entries that need attention first.

  3. 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§

Counts
The counts shown in the status header.
Entry
One file, reduced to what the summary needs.

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.