{"record":{"id":"20dac4fdde1dee74","repo":"Hmbown/CodeWhale","slug":"new-worktree-requires-a-git-repository","errorCode":null,"errorMessage":"new worktree requires a Git repository","messagePattern":"new worktree requires a Git repository","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/ui/session_state.rs","lineNumber":566,"sourceCode":"    }\n    if slug.is_empty() {\n        format!(\"session-{}\", chrono::Utc::now().format(\"%Y%m%d-%H%M%S\"))\n    } else {\n        slug\n    }\n}\n\npub(crate) fn launch_worktree_spec(\n    workspace: &std::path::Path,\n    requested: &str,\n) -> Result<codewhale_lane::WorktreeProvision> {\n    let output = std::process::Command::new(\"git\")\n        .current_dir(workspace)\n        .args([\"rev-parse\", \"--show-toplevel\"])\n        .output()\n        .context(\"inspect Git repository for new worktree\")?;\n    if !output.status.success() {\n        anyhow::bail!(\"new worktree requires a Git repository\");\n    }\n    let repo_root = PathBuf::from(String::from_utf8(output.stdout)?.trim());\n    let repo_name = repo_root\n        .file_name()\n        .and_then(|name| name.to_str())\n        .filter(|name| !name.is_empty())\n        .unwrap_or(\"workspace\");\n    let slug = launch_worktree_slug(requested);\n    let parent = repo_root.parent().unwrap_or(repo_root.as_path());\n    let path = parent\n        .join(\".codewhale-worktrees\")\n        .join(format!(\"{repo_name}-{slug}\"));\n    if path.exists() {\n        anyhow::bail!(\"worktree path already exists: {}\", path.display());\n    }\n    Ok(codewhale_lane::WorktreeProvision {\n        repo_root,\n        branch: format!(\"codex/{slug}\"),","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/ui/session_state.rs#L548-L584","documentation":"Raised in launch_worktree_spec when `git rev-parse --show-toplevel` run in the workspace exits unsuccessfully, meaning the workspace is not inside a Git repository. Creating a worktree requires a repository root to anchor the new worktree's location, so provisioning is refused for plain directories.","triggerScenarios":"Thrown at crates/tui/src/tui/ui/session_state.rs:566 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the worktree launch from inside a Git repository","Initialize Git in the workspace with git init if it should be a repo","Verify the working directory is the intended project checkout"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}