Files
tty7/crates
l0ng-ai df6f028685 feat(git): parse porcelain v2 into a working tree status
Adds the parser and the probe behind the source control panel: one
`git status --porcelain=v2 --branch --show-stash -uall -z` per refresh,
read through `Host::git` so the NUL stream survives a remote workspace
byte for byte (`git_lines` would reassemble it into one giant line).

- `parse_porcelain_v2` is pure and infallible: headers, `1`, `2`, `u`,
  `?` and `!` records, submodule sub-state, rename scores. A `2` record
  spends two NUL tokens, so the parser parks the half-built entry and
  takes the *next* record as the old path — a regression test asserts
  the row behind a rename is not swallowed.
- `probe_status` costs three round trips: `rev-parse`, `status`, and one
  `read_dir` of the git dir for the sequencer operation. The operation
  precedence mirrors git's own `wt_status_print_state`; only a parked
  rebase pays for a second `read_dir` to tell `am` from rebase and `-i`
  from plain.
- `StatusIndex::build` folds a status into the file tree's lookup, and
  drops the per-file map past `MAX_DECORATED_FILES`.

Two behaviours were measured on git 2.50.1 and shaped the code:

- `status.aheadBehind=false` does *not* suppress `# branch.ab` for
  porcelain v2 (the config is documented for non-porcelain formats), and
  `--no-ahead-behind` prints `+? -?` rather than dropping the line. So
  `+? -?` parses as *unknown*, never as in sync, and the `rev-list
  --left-right --count` fallback fires only when the line is missing —
  unconditionally re-asking would cost a remote RPC on every refresh for
  a number we almost always already have.
- `-c core.quotePath=false` is a no-op under `-z`, which disables
  C-quoting on its own. It is kept for consistency with the other git
  invocations, not because it fixes anything here.

`repo_home` becomes `pub(crate)` so the probe can reuse the one
`rev-parse` that already resolves root, git dir and common dir.
2026-08-09 00:30:20 +08:00
..