{"record":{"id":"0f366a3c20ca277c","repo":"gitbutlerapp/gitbutler","slug":"configured-storage-path-resolves-to-git-it","errorCode":null,"errorMessage":"configured storage path '{}' resolves to '.git' itself; choose a dedicated GitButler directory instead","messagePattern":"configured storage path '(.+?)' resolves to '\\.git' itself; choose a dedicated GitButler directory instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-project-handle/src/storage_path.rs","lineNumber":91,"sourceCode":"    }\n\n    let gitdir_real = gix::path::realpath(git_dir)?;\n    Ok(storage_path\n        .strip_prefix(&gitdir_real)\n        .ok()\n        .map(Path::to_owned))\n}\n\n/// Only accept `storage_path_relative_to_git_dir` if it's a top-level `gitbutler` directory.\n/// Use `storage_path` to format error messages.\nfn validate_in_git_storage_path(\n    storage_path_relative_to_git_dir: &Path,\n    storage_path: &Path,\n) -> anyhow::Result<()> {\n    let Some(Component::Normal(top_level_dir)) =\n        storage_path_relative_to_git_dir.components().next()\n    else {\n        bail!(\n            \"configured storage path '{}' resolves to '.git' itself; choose a dedicated GitButler directory instead\",\n            storage_path.display()\n        );\n    };\n\n    if !top_level_dir\n        .to_string_lossy()\n        .get(..DEFAULT_STORAGE_DIR_NAME.len())\n        .is_some_and(|name| name.eq_ignore_ascii_case(DEFAULT_STORAGE_DIR_NAME))\n    {\n        bail!(\n            \"configured storage path '{}' resolves inside '.git' but not under a top-level 'gitbutler*' directory\",\n            storage_path.display()\n        );\n    }\n\n    Ok(())\n}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-project-handle/src/storage_path.rs#L73-L109","documentation":"When resolving a configured GitButler storage path that lives inside .git, the library validates that the path is under a dedicated subdirectory rather than at .git itself. This error fires when the configured path resolves exactly to the .git directory, which would collide with Git's own metadata.","triggerScenarios":"Setting the storage path configuration such that `storage_path_relative_to_git_dir` has no components (i.e. it is '.' or empty relative to the git dir) and calling `resolve_configured_storage_path`.","commonSituations":"A config typo where the storage dir is set to '.' or the git dir itself; automated config generation that strips the subdirectory component; migrating configs between repo layouts.","solutions":["Change the configured storage path to a dedicated subdirectory inside .git (e.g. .git/gitbutler/storage)","Validate the resolved path has at least one component below .git before persisting config","If the intent was a directory outside .git, configure an absolute path outside the git dir"],"exampleFix":"// before (.gitconfig)\n[gitbutler]\n\tstoragePath = .\n// after\n[gitbutler]\n\tstoragePath = gitbutler/storage","handlingStrategy":"validation","validationCode":"let rel = storage_path.strip_prefix(git_dir)?;\nif rel.components().next().is_none() {\n    anyhow::bail!(\"storage path must be a subdirectory of .git, not .git itself\");\n}","typeGuard":"fn is_dotgit_itself(p: &std::path::Path, git_dir: &std::path::Path) -> bool {\n    p == git_dir\n}","tryCatchPattern":"match resolve_configured_storage_path(&repo) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"resolves to '.git' itself\") => {\n        eprintln!(\"fix [gitbutler] storagePath in config to a subdirectory\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never configure '.' or the git dir as storagePath","Validate config values before persisting them","Prefer paths like .git/gitbutler/<subdir>"],"tags":["git","configuration","storage-path"],"backgroundTag":"invalid-config-value","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}