{"record":{"id":"91f13d9b4f6d2d1a","repo":"can1357/oh-my-pi","slug":"not-a-git-repository-cwd","errorCode":null,"errorMessage":"Not a git repository: ${cwd}","messagePattern":"Not a git repository: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/git-tui/index.ts","lineNumber":806,"sourceCode":"\t}\n}\n\n/** Options for {@link runGitTui}. */\nexport interface GitTuiOptions {\n\tcwd?: string;\n\t/** Pin the view to one commit (any rev-parse-able revision). */\n\trevision?: string;\n}\n\n/**\n * Mount the git TUI as a fullscreen overlay on an existing TUI (the `/git`\n * slash command). Resolves when the user closes it; the caller restores focus.\n */\nexport async function showGitOverlay(ui: TUI, options: GitTuiOptions = {}): Promise<void> {\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst repo = vcs.git(cwd);\n\tconst root = repo?.info().repoRoot ?? null;\n\tif (!root) throw new Error(`Not a git repository: ${cwd}`);\n\tlet pinnedSha: string | undefined;\n\tif (options.revision) {\n\t\tpinnedSha = (await repo?.resolveRef(options.revision)) ?? undefined;\n\t\tif (!pinnedSha) throw new Error(`Cannot resolve revision: ${options.revision}`);\n\t}\n\tconst component = new GitTuiComponent(ui, root, pinnedSha);\n\tconst overlay = ui.showOverlay(component, {\n\t\tanchor: \"top-left\",\n\t\twidth: \"100%\",\n\t\tmaxHeight: \"100%\",\n\t\tmargin: 0,\n\t\tfullscreen: true,\n\t\tmouseTracking: true,\n\t});\n\tui.setFocus(component);\n\tui.requestRender();\n\ttry {\n\t\tawait component.run();","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/git-tui/index.ts#L788-L824","documentation":"showGitOverlay opens the git TUI overlay and first resolves the repository root via vcs.git(cwd). If git is unavailable or the directory is not inside a git work tree (repoRoot is null), it throws with the offending cwd. The overlay requires a real git repository to enumerate status/branches.","triggerScenarios":"Calling showGitOverlay (or the git TUI command) with options.cwd set to (or the process started in) a directory outside any git work tree, or in a bare/worktree configuration where repoRoot cannot be resolved.","commonSituations":"Running the git overlay from $HOME or /tmp, inside a plain directory that was never `git init`ed, or with GIT_DIR pointing somewhere invalid.","solutions":["cd into (or pass options.cwd of) a directory inside a git repository.","Initialize a repository with `git init` if one is intended.","Check GIT_DIR/GIT_WORK_TREE env overrides that may break root resolution."],"exampleFix":"// before\nawait showGitOverlay(ui, { cwd: \"/tmp\" });\n// after\nconst cwd = \"/home/me/project\"; // inside a git repo\nawait showGitOverlay(ui, { cwd });","handlingStrategy":"validation","validationCode":"import { $ } from \"bun\";\nconst inside = await $`git -C ${cwd} rev-parse --show-toplevel`.quiet().nothrow();\nif (inside.exitCode !== 0) throw new Error(`Not a git repo: ${cwd}`);","typeGuard":null,"tryCatchPattern":"try {\n  await showGitOverlay(ui, { cwd });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"Not a git repository\")) {\n    console.error(\"Open the git TUI from inside a git repository.\");\n    return;\n  }\n  throw e;\n}","preventionTips":["Resolve cwd to the repo root (or verify with `git rev-parse --show-toplevel`) before opening.","Unset bogus GIT_DIR/GIT_WORK_TREE overrides.","Gate the command in wrappers on repository presence."],"tags":["git","environment","guard-clause"],"backgroundTag":"not-a-git-repository","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}