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§
- File
Hunks - One changed file, read and diffed: the working-tree text plus the post-image ranges its hunks occupy.
- Magit
Project Diff Mode magit-project-diff-mode— the provider-minor activated on a project-diff view.- Magit
Project Diff Mode Guard - PD.7c: holds the staleness subscription for one view. Dropping it
(buffer closed, mode deactivated) unsubscribes and stops the
forwarder — the same RAII shape
ProjectSearchModeGuarduses. - Project
Diff Deletion Rows - The view-touching half. Spawn a source document per file, add it
to
view’s source map, and append one excerpt per hunk. - Project
Diff Service - Per-view state keyed by the view’s
BufferId, plus aDocumentId → BufferIdindex for cleanup. - Project
Diff State - Per-view state: what it compares, and where.
Enums§
- Project
Diff Comparison - 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-diffand the Diff transient’serow — name it. - REFRESH_
ACTION - PD.7c: the action
grresolves to in this view, declared byMagitProjectDiffMode::refresh_actionand 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§
- Project
Diff Service Handle - Register and look up under THIS alias, never the inner type — the
ServiceRegistrykeys onTypeId, so registering anArc<ProjectDiffService>and asking forProjectDiffServicesilently returnsNone.