Skip to main content

Module content

Module content 

Source
Expand description

Bounded content read beside the stats scan: what a seat’s changed files say, as raw unified-diff hunks.

The sibling of super::scan, not a layer inside it: the stats scan is polled (1 Hz on a moving tree, 10 s when still) and its prev is the PR-lookup cache, while this read is taken for a seat’s record on the reads that encode one - a cold load, a reconnect, a seat swap - and never polled.

One parser for both readers: the hunks and statuses are super::hunks’ own, and only the caps below are this read’s. A record is re-encoded per read and re-sent on reconnect, so no read may carry an unbounded diff, and every cap has a flag beside it rather than a silence.

Both layers the snapshot carries are read with the refs the caller has just established - HEAD for the worktree layer, and the base the drawing read refreshed for the branch-ahead one - so a file’s row and its content describe one tree, with base saying how current that base is.

Re-exports§

use std::path::Path; 🔒
use serde::Deserialize; 🔒
use serde::Deserialize; 🔒
use serde::Serialize; 🔒
use serde::Serialize; 🔒
use forge_primitives::git_diff::BaseState; 🔒
use forge_primitives::git_diff::GitDiffSnapshot; 🔒
use forge_primitives::git_diff::LayerState; 🔒
use super::hunks::FileStatus; 🔒
use super::hunks::Hunk; 🔒
use super::hunks::MAX_INFLIGHT_FETCHES; 🔒
use super::hunks::NameStatusEntry; 🔒
use super::hunks::parse_hunks; 🔒
use super::hunks::parse_name_status_entries; 🔒
use std::time::Duration; 🔒
use super::COMMAND_TIMEOUT; 🔒
use super::GitOutput; 🔒
use super::run_git_within; 🔒

Structs§

Caps 🔒
The read’s budget, spent as content is carried across both layers.
CommitContent
One commit’s own diff as bounded content.
DiffContent
The changed files of a seat’s two diff layers, bounded and flagged.
FileContent
One changed file’s bounded content.

Constants§

CONTEXT_LINES
Unified-diff context lines each per-file fetch pins. git’s own default: enough to read a change in place, small enough that a one-line edit to a huge file does not carry the file.
MAX_FILES
The most files the read fetches content for, both layers together. Each fetch is a subprocess, so this is the read’s work bound where the byte caps are its payload bound; a file past it keeps its status and is flagged truncated.
MAX_FILE_BYTES
Carried bytes per file - the cap a file of few but long lines meets first.
MAX_FILE_LINES
Carried lines per file. A generated file’s rewrite must not carry its whole body into a record that is re-sent on every subscribe.
MAX_TOTAL_BYTES
Carried line text across the whole read, both layers together. The JSON envelope the record adds beside it is not counted here; the bound is on the diff’s own content.

Functions§

branch_range 🔒
The ref range the branch-ahead layer is read with: the merge-base form the stats scan composes (<default>...HEAD), so a file’s row and its content stay one tree after a squash-merge.
fetch_section 🔒
One file’s diff section, None when git would not answer it (a crash or a read past the subprocess cap). A binary body and an empty one both answer Some.
fold_hunks 🔒
Carry one section’s hunks under the per-file caps and the read’s total, answering what is carried and whether anything was cut.
fold_one 🔒
One entry and its fetched section as a file row. None is a fetch that was withheld or never made: the row keeps its status and says its content is missing.
scan
Read both layers of snapshot for cwd into bounded content.
scan_commit
Read one commit’s own diff as bounded content, under its own budget.
scan_commit_within
scan_commit with its command budget spelled: the budget is a bound on the machine, not on the read, spent starting each child the read spawns.
scan_layer 🔒
Read one layer: its file list, then one bounded fetch per file.
scan_within
scan with its command budget spelled; the budget bounds the machine’s start of each child, not the read’s own work.
section_is_binary 🔒
git prints one of these instead of hunks when it will not diff the bytes - on both sides, or the null side of a new/deleted file.
section_is_submodule 🔒
A gitlink: git prints the mode 160000 on one of the entry’s header lines (index a..b 160000, new file mode 160000, old mode 160000), and the body is a pair of commit ids.