{"record":{"id":"985222843a9ef763","repo":"gitbutlerapp/gitbutler","slug":"configured-storage-path-resolves-inside-git","errorCode":null,"errorMessage":"configured storage path '{}' resolves inside '.git' but not under a top-level 'gitbutler*' directory","messagePattern":"configured storage path '(.+?)' resolves inside '\\.git' but not under a top-level 'gitbutler\\*' directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-project-handle/src/storage_path.rs","lineNumber":102,"sourceCode":"fn 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}\n\n/// Name of the default GitButler storage directory inside the git dir.\npub const DEFAULT_STORAGE_DIR_NAME: &str = \"gitbutler\";\n\n/// Git-dir-relative path of the refresh sentinel, `gitbutler/REFRESH`.\n///\n/// Single source of truth shared by the writer (`write_refresh_sentinel`) and\n/// the watcher (`gitbutler_filemonitor`).\npub const REFRESH_SENTINEL_PATH: &str = \"gitbutler/REFRESH\";\n\n/// Identity written into the refresh sentinel so a process can skip the write","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-project-handle/src/storage_path.rs#L84-L120","documentation":"GitButler reserves a top-level 'gitbutler*' directory inside .git for its storage. This error fires when a configured storage path resolves inside .git but under some other top-level directory, which could conflict with Git internals or other tools.","triggerScenarios":"Calling `resolve_configured_storage_path` with a config value whose path, relative to the git dir, starts with a top-level component not prefixed with 'gitbutler' (case-insensitive), e.g. '.git/refs/storage' or '.git/mydata'.","commonSituations":"Hand-editing .gitconfig and choosing an arbitrary subdirectory; scripts that compute a storage location without the naming convention; copy-pasting a path from another tool.","solutions":["Rename the configured storage path so its first component starts with 'gitbutler' (e.g. .git/gitbutler/storage)","If external storage is needed, configure a path outside .git entirely","Re-run resolution after fixing the config to confirm validation passes"],"exampleFix":"// before (.gitconfig)\n[gitbutler]\n\tstoragePath = refs/gbdata\n// after\n[gitbutler]\n\tstoragePath = gitbutler/gbdata","handlingStrategy":"validation","validationCode":"let rel = storage_path.strip_prefix(git_dir)?;\nlet ok = rel.components().next()\n    .map(|c| c.as_os_str().to_string_lossy().to_lowercase().starts_with(\"gitbutler\"))\n    .unwrap_or(false);\nanyhow::ensure!(ok, \"storage path inside .git must start with a 'gitbutler*' directory\");","typeGuard":"fn is_gitbutler_dir(p: &std::path::Path) -> bool {\n    p.components().next()\n        .map(|c| c.as_os_str().to_string_lossy().to_lowercase().starts_with(\"gitbutler\"))\n        .unwrap_or(false)\n}","tryCatchPattern":"match resolve_configured_storage_path(&repo) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"gitbutler*\") => {\n        eprintln!(\"rename configured storage dir to a gitbutler* prefix\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Follow the gitbutler* naming convention for in-.git storage","Keep storage outside .git when custom locations are needed","Lint generated configs for the reserved prefix"],"tags":["git","configuration","naming-convention"],"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"}