Skip to main content

Module project_diff

Module project_diff 

Source
Expand description

PD.1 (2026-08-12): the project-diff view — every changed file in the working tree as one editable multibuffer.

Design: docs/dev/architecture/magit-project-diff.md. Slice plan: docs/dev/operations/slice-plans/magit-project-diff.md. Catalogue entry: A.1 in slice-plans/multibuffer-providers.md.

§The gap this fills

Magit already diffs in two shapes and neither is this one. magit-status’s sections are patch text built for staging; *magit:diff:<path>* reads well but is one file at a time and still patch text. Missing is every changed file at once, as real source you can edit — you spot a typo in file 19 of a 30-file review and today you must leave the diff, open the file, fix it, come back.

§Excerpts anchor in the working-tree file

An excerpt is a hunk’s post-image range in the file on disk, so edits propagate through the ordinary M.3 pipeline with no patch application and no write-back path of its own.

That anchoring is also the constraint: only the working tree is a file. A staged-vs-HEAD or rev..rev comparison has an index blob as its post-image, with nothing for an edit to land in, so those open read-only rather than getting an invented index-write-back path. Read-only there is the correct rendering of a comparison between two things that are not the file on disk — not a degraded mode.

Structs§

FileHunks
One changed file, read and diffed: the working-tree text plus the post-image ranges its hunks occupy.
MagitProjectDiffMode
magit-project-diff-mode — the provider-minor activated on a project-diff view.
MagitProjectDiffModeGuard
PD.7c: holds the staleness subscription for one view. Dropping it (buffer closed, mode deactivated) unsubscribes and stops the forwarder — the same RAII shape ProjectSearchModeGuard uses.
ProjectDiffDeletionRows
The view-touching half. Spawn a source document per file, add it to view’s source map, and append one excerpt per hunk.
ProjectDiffService
Per-view state keyed by the view’s BufferId, plus a DocumentId → BufferId index for cleanup.
ProjectDiffState
Per-view state: what it compares, and where.

Enums§

ProjectDiffComparison
Which comparison a project-diff view shows.

Constants§

PROVIDER_NAME
The name this provider is registered under in the [ProviderViewRegistry]. Both front-ends — :magit-project-diff and the Diff transient’s e row — name it.
REFRESH_ACTION
PD.7c: the action gr resolves to in this view, declared by MagitProjectDiffMode::refresh_action and handled by the same mode.
VIEW_NAME
The view’s buffer name. Stable, so re-triggering finds the buffer the user already has open instead of stacking a second one beside it under the same name (which would make :b *magit:project-diff* ambiguous).

Functions§

attach_batch
changed_lines
One changed file’s hunks, as excerpt line ranges over the working-tree file.
file_hunk_ranges
open_project_diff
Open (or re-drive) the project-diff view.
read_and_diff
The blocking half. Read each changed file and compute its hunk ranges against the baseline the scan collected.
register_project_diff_mode
register_project_diff_provider
Register the view opener on the generic provider-view seam.
removed_lines
PD.7b: text the diff removed, grouped by the post-image line the removal sits above.
scan_changed_files
Collect the changed files and their baseline text.

Type Aliases§

ProjectDiffServiceHandle
Register and look up under THIS alias, never the inner type — the ServiceRegistry keys on TypeId, so registering an Arc<ProjectDiffService> and asking for ProjectDiffService silently returns None.