{"record":{"id":"0ac1a31249060a7c","repo":"nikivdev/code","slug":"derived-shared-repo-root-does-not-contain-git","errorCode":null,"errorMessage":"derived shared repo root {} does not contain .git","messagePattern":"derived shared repo root (.+?) does not contain \\.git","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pr_preview.rs","lineNumber":1425,"sourceCode":"    .canonicalize()\n    .with_context(|| {\n        format!(\n            \"failed to resolve JJ repo pointer for {}\",\n            workspace_root.display()\n        )\n    })?;\n    let repo_root = jj_repo_dir\n        .parent()\n        .and_then(Path::parent)\n        .map(Path::to_path_buf)\n        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"failed to derive shared repo root from {}\",\n                jj_repo_dir.display()\n            )\n        })?;\n    if !repo_root.join(\".git\").exists() {\n        bail!(\n            \"derived shared repo root {} does not contain .git\",\n            repo_root.display()\n        );\n    }\n    Ok(repo_root)\n}\n\nfn detect_jj_head_ref(workspace_root: &Path) -> Result<String> {\n    let output = Command::new(\"jj\")\n        .current_dir(workspace_root)\n        .args([\"log\", \"-r\", \"@ | @-\", \"--no-graph\", \"-T\", \"bookmarks\"])\n        .output()\n        .with_context(|| format!(\"failed to run jj log in {}\", workspace_root.display()))?;\n    if !output.status.success() {\n        bail!(\"jj log failed in {}\", workspace_root.display());\n    }\n    let mut bookmarks = parse_jj_bookmark_tokens(&String::from_utf8_lossy(&output.stdout));\n    bookmarks.sort();","sourceCodeStart":1407,"sourceCodeEnd":1443,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/pr_preview.rs#L1407-L1443","documentation":"After deriving a shared repo root from the jj repo directory, the code sanity-checks that the derived root actually contains a `.git` entry. If it does not, the derivation is wrong (or the workspace is not git-colocated) and this error names the bad root path.","triggerScenarios":"resolve_repo_root_from_jj_workspace derives a root whose `.git` check fails — e.g. a non-colocated jj repo, or the `.jj/repo` pointer resolving to an unexpected location.","commonSituations":"jj workspaces created without git colocation; custom or relocated jj repo stores; version changes in jj's layout altering how the root should be derived.","solutions":["Ensure the repo is git-colocated (`jj git init --colocate`) or verify `.git` exists at the expected root","Check that `.jj/repo` points to the correct store for this workspace","Operate directly on the git work tree instead of via the jj workspace"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let root = resolve_repo_root_from_jj_workspace(ws)?;\nif !root.join(\".git\").exists() {\n    anyhow::bail!(\"{} is not git-colocated\", root.display());\n}","typeGuard":"fn is_git_colocated(root: &Path) -> bool {\n    root.join(\".git\").exists()\n}","tryCatchPattern":"if let Err(e) = run_pr_preview(cmd) {\n    if e.to_string().contains(\"does not contain .git\") {\n        eprintln!(\"Use a git-colocated jj workspace or the git work tree\");\n    }\n}","preventionTips":["Create jj repos with git colocation (`jj git init --colocate`)","Verify .git exists at the expected root before previewing","Point --path at the git work tree for non-colocated workspaces"],"tags":["jj","jujutsu","git","pr","filesystem"],"backgroundTag":"vcs-workspace-resolution-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}