{"record":{"id":"4e08d0bf47834fc5","repo":"nikivdev/code","slug":"not-a-git-repository-4e08d0","errorCode":null,"errorMessage":"Not a git repository","messagePattern":"Not a git repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/jj.rs","lineNumber":3578,"sourceCode":"        .output();\n    match output {\n        Ok(out) => String::from_utf8_lossy(&out.stdout)\n            .lines()\n            .filter(|l| !l.trim().is_empty())\n            .map(|l| l.trim().to_string())\n            .collect(),\n        Err(_) => Vec::new(),\n    }\n}\n\nfn git_dir(repo_root: &Path) -> Result<PathBuf> {\n    let output = Command::new(\"git\")\n        .current_dir(repo_root)\n        .args([\"rev-parse\", \"--git-dir\"])\n        .output()\n        .context(\"failed to locate git directory\")?;\n    if !output.status.success() {\n        bail!(\"Not a git repository\");\n    }\n    let raw = String::from_utf8_lossy(&output.stdout).trim().to_string();\n    let dir = PathBuf::from(raw);\n    if dir.is_absolute() {\n        Ok(dir)\n    } else {\n        Ok(repo_root.join(dir))\n    }\n}\n\nfn workspace_default_path(repo_root: &Path, name: &str) -> Result<PathBuf> {\n    let home = std::env::var(\"HOME\").context(\"HOME not set\")?;\n    let repo_name = repo_root\n        .file_name()\n        .and_then(|n| n.to_str())\n        .unwrap_or(\"repo\");\n    Ok(PathBuf::from(home)\n        .join(\".jj\")","sourceCodeStart":3560,"sourceCodeEnd":3596,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/jj.rs#L3560-L3596","documentation":"The git_dir locator runs `git rev-parse --git-dir`; if git exits non-zero the caller is not inside a git repository, so it bails with 'Not a git repository'. This validates the environment before any repo-relative path resolution.","triggerScenarios":"Any command that resolves the git dir (run from an unexpected cwd) executes `git rev-parse --git-dir` outside a work tree or in a repo where git fails (corrupt config, missing .git).","commonSituations":"Running flow from a subdirectory outside the repo, from $HOME, or in a checkout where .git was deleted; PATH lacking a working git binary causing spawn/context errors upstream; GIT_DIR env pointing at a nonexistent location.","solutions":["cd into your project checkout (the one containing .git / the jj colocated repo) and re-run the command.","Verify `git rev-parse --git-dir` succeeds manually in that directory.","If .git is genuinely missing, re-clone or restore the repo before using flow."],"exampleFix":"// before\ncd ~ && flow sync   # Not a git repository\n// after\ncd ~/code/my-project   # inside the repo\nflow sync","handlingStrategy":"validation","validationCode":"// shell\ngit rev-parse --git-dir >/dev/null 2>&1 || { echo \"run from inside the repository\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Anchor scripts with cd \"$(git rev-parse --show-toplevel)\" before invoking flow.","Check GIT_DIR/GIT_WORK_TREE env overrides that can redirect rev-parse unexpectedly.","Verify .git exists after cloning or restoring backups."],"tags":["git","environment","repo-detection","cwd"],"backgroundTag":"not-a-git-repository","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}