{"record":{"id":"6e06cb28cddb3c63","repo":"zed-industries/zed","slug":"git-worktree-directory-must-not-be-use-s","errorCode":null,"errorMessage":"git.worktree_directory must not be \"..\" (use \"../some-name\" instead)","messagePattern":"git\\.worktree_directory must not be \"\\.\\.\" \\(use \"\\.\\./some-name\" instead\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/project/src/git_store.rs","lineNumber":10503,"sourceCode":"    // is absolute but becomes \"\" after stripping trailing separators.\n    // Also check for leading `/` or `\\` explicitly, because on Windows\n    // `Path::is_absolute()` requires a drive letter — so `/tmp/worktrees`\n    // would slip through even though it's clearly not a relative path.\n    if path_style.is_absolute(worktree_directory_setting)\n        || worktree_directory_setting.starts_with('\\\\')\n    {\n        anyhow::bail!(\n            \"git.worktree_directory must be a relative path, got: {worktree_directory_setting:?}\"\n        );\n    }\n\n    if worktree_directory_setting.is_empty() {\n        anyhow::bail!(\"git.worktree_directory must not be empty\");\n    }\n\n    let trimmed = worktree_directory_setting.trim_end_matches(['/', '\\\\']);\n    if trimmed == \"..\" {\n        anyhow::bail!(\"git.worktree_directory must not be \\\"..\\\" (use \\\"../some-name\\\" instead)\");\n    }\n\n    let joined = path_style.join_path(repository_anchor_path, trimmed)?;\n    let resolved = if path_style.is_posix() {\n        joined\n    } else {\n        path::normalize_path(&joined)\n    };\n    let resolved = if resolved.starts_with(repository_anchor_path) {\n        resolved\n    } else if let Some(repo_dir_name) = repository_anchor_path\n        .file_name()\n        .and_then(|name| name.to_str())\n    {\n        path_style.join_path(&resolved, repo_dir_name)?\n    } else {\n        resolved\n    };","sourceCodeStart":10485,"sourceCodeEnd":10521,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/project/src/git_store.rs#L10485-L10521","documentation":"After trimming trailing separators, a worktree_directory value equal to exactly \"..\" would resolve the worktree directory to the repository's parent directory itself, colliding with the repo's own directory (crates/project/src/git_store.rs:10503). Zed rejects it and asks for a named sibling like \"../some-name\" instead.","triggerScenarios":"Setting git.worktree_directory to \"..\", or values that reduce to it after trimming trailing separators, such as \"../\" or \"..\\\\\".","commonSituations":"Users trying to scatter worktrees directly in the folder that contains their repos, without a naming prefix.","solutions":["Use a named sibling directory: \"../my-repo-worktrees\"","Or keep worktrees inside the repository: \".worktrees\""],"exampleFix":"// settings.json - before\n{ \"git\": { \"worktree_directory\": \"..\" } }\n\n// settings.json - after\n{ \"git\": { \"worktree_directory\": \"../acme-worktrees\" } }","handlingStrategy":"validation","validationCode":"let trimmed = setting.trim_end_matches(['/', '\\\\']);\nif trimmed == \"..\" {\n    return Err(\"git.worktree_directory must not be \\\"..\\\" (use \\\"../some-name\\\" instead)\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always name worktree directories (\"../repo-worktrees\"), never a bare parent reference","Mirror Zed's trailing-separator trimming when pre-validating configs"],"tags":["git","worktree","settings","configuration","path-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}