Skip to main content

read_state

Function read_state 

Source
pub fn read_state(
    repo_root: &Path,
    home_override: Option<&Path>,
) -> Result<StateV2, WorktreeError>
Expand description

Read and parse state.json, migrating from v1 if needed. If the file is missing, returns a fresh empty state.

If the file exists but cannot be parsed as JSON, the corrupt file is renamed to state.json.corrupt.<timestamp> and a fresh empty state is returned. The next list() will repopulate active worktrees from git worktree list. A migration failure (unknown schema version) is surfaced as StateCorrupted — we don’t clobber data we can’t interpret.