Skip to main content

discover

Function discover 

Source
pub fn discover(worktree_root: &Path) -> Result<RepoLayout, DiscoverError>
Expand description

Resolve the RepoLayout for the repository whose working tree is rooted at worktree_root (#493 Phase 1 discovery).

  • .mkit is a directory, or absent: the classic single-worktree layout (RepoLayout::single) — absence is NOT an error here so the store-open path keeps producing today’s “not a repository” diagnostics unchanged.
  • .mkit is a FILE: a linked worktree. The pointer is parsed (mkitdir: <path>, absolute or relative to worktree_root), the per-tree state dir must exist, and the common dir is resolved via the state dir’s commondir file (defaulting to ../.. when the file is absent, matching what worktree add writes) and must exist. Every failure along that chain is a typed, fail-closed DiscoverError — a broken linked tree must never silently degrade into “operate on some other directory”.

§Errors

See DiscoverError.