Expand description
Which project a path belongs to (slice PR.1).
Design: project-resolution.md.
A project is a pure function of a path with a cache in front of it. There is no “current project” here — no mutable session state to persist, invalidate, or fall out of sync. Multiple projects therefore co-exist by construction: buffers from three checkouts each answer with their own, and an action in one cannot re-root another because there is no shared cell for it to write.
§Why for_path is total
ProjectResolver::for_path returns Project, never
Option<Project>. That signature is the design. lattice-magit’s
workdir.rs records what the alternative produced: eleven
hand-written copies of the same discovery, three of them passing a
file where a directory was required and silently defaulting — one of
which meant gutter diff signs had never worked, for any file, since
they landed. Every caller writing its own .unwrap_or_else(cwd) is
every caller getting a chance to write it wrong. A consumer that
cannot express “no project” cannot get “no project” wrong.
§Why no gix
.git is the first marker, and a marker walk is sufficient: a .git
entry marks a worktree root whether it is a directory (ordinary
clone) or a file (submodule, git worktree add). The walk and
gix::discover therefore agree in every case a user will meet; they
diverge only under GIT_WORK_TREE / GIT_DIR, core.worktree, and
ceiling directories.
That divergence is accepted deliberately. Only three crates depend on
lattice-vcs today, and every crate depends on this one — routing
resolution through gix would pull a heavy compile-time and
binary-size dependency behind lattice-core and therefore into the
whole workspace, to walk up a directory tree. magit is the one
consumer for which the distinction is load-bearing, and it keeps its
own gix discovery because it needs the Repository object anyway.
ProjectResolver is a trait, so this is reversible: a
gix-backed impl can be registered later without any consumer
changing.
Structs§
- Excerpt
Source - Where a composed line came from: the source document, its file, and the 0-based line within it.
- Marker
Resolver - The built-in
ProjectResolver: walk up for a marker, else pwd. - Project
- The project a path belongs to.
Enums§
- Project
Kind - How a
Project’s root was decided — for:project-root, for diagnostics, and for the rare consumer that legitimately cares (magit wants a VCS root specifically; a terminal does not).
Constants§
- DEFAULT_
ROOT_ MARKERS - The markers a project root is recognised by, in priority order within a single directory.
Traits§
- Excerpt
Source Resolver - Answers where a line of a composed (multibuffer) buffer came from.
- Project
Resolver - Resolves paths to projects.
- View
Args Resolver - What arguments a provider view is currently showing (slice OA.27).
Functions§
- root_
from_ cwd - The project root containing the process’s working directory, over the default markers.
Type Aliases§
- Excerpt
Source Resolver Handle - Shared handle to an
ExcerptSourceResolver. - Project
Resolver Handle - Per the
ServiceRegistryArc/TypeId convention: register and look up under this exact alias. - View
Args Resolver Handle - Shared handle to a
ViewArgsResolver.