Yeachan-Heo/oh-my-codex · error · Error
(result.stderr || '').trim() || `git status failed for ${wor
Error message
(result.stderr || '').trim() || `git status failed for ${worktreePath}` What it means
gitStatusLines runs `git status --porcelain --untracked-files=all` in the worktree and throws the stderr or a generic message when the command exits non-zero. It is the entry point for all worktree cleanliness inspection in the autoresearch runtime.
Source
Thrown at src/autoresearch/runtime.ts:241
function requireGitSuccess(worktreePath: string, args: string[]): void {
const result = spawnSync('git', args, {
cwd: worktreePath,
encoding: 'utf-8',
windowsHide: true,
});
if (result.status === 0) return;
throw new Error((result.stderr || '').trim() || `git ${args.join(' ')} failed`);
}
function gitStatusLines(worktreePath: string): string[] {
const result = spawnSync('git', ['status', '--porcelain', '--untracked-files=all'], {
cwd: worktreePath,
encoding: 'utf-8',
windowsHide: true,
});
if (result.status !== 0) {
throw new Error((result.stderr || '').trim() || `git status failed for ${worktreePath}`);
}
return (result.stdout || '')
.split(/\r?\n/)
.map((line) => line.trimEnd())
.filter(Boolean);
}
function isAllowedRuntimeDirtyLine(line: string): boolean {
const trimmed = line.trim();
if (trimmed.length < 4) return false;
const path = trimmed.slice(3).trim();
return trimmed.startsWith('?? ') && AUTORESEARCH_WORKTREE_EXCLUDES.some((exclude) => exclude.endsWith('/')
? path.startsWith(exclude) || path === exclude.slice(0, -1)
: path === exclude);
}
export function assertResetSafeWorktree(worktreePath: string): void {
const lines = gitStatusLines(worktreePath);View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Run `git status --porcelain --untracked-files=all` in the printed worktreePath to see the underlying error
- For 'detected dubious ownership', run `git config --global --add safe.directory <path>` or match user ownership
- If the index is corrupt, delete the worktree's index file and let git rebuild it, or recreate the worktree
- If the main repo of a linked worktree is gone, remove and recreate the worktree
Defensive patterns
Strategy: try-catch
Validate before calling
import { spawnSync } from 'node:child_process';
function statusWorks(worktreePath: string): boolean {
return spawnSync('git', ['status', '--porcelain'], { cwd: worktreePath }).status === 0;
} Try / catch
try { assertResetSafeWorktree(worktreePath); }
catch (e) { if (e instanceof Error && /git status failed/.test(e.message)) { /* run git status manually; check safe.directory and index integrity */ } throw e; } Prevention
- Set git safe.directory when repo and process owners differ
- Avoid deleting the main repo behind linked worktrees
- Keep .git/index intact; avoid killing processes mid-status
When it happens
Trigger: Any call path that inspects worktree status (assertResetSafeWorktree, prepare/resume runtime) when git status fails: corrupt index file, invalid .git link in a linked worktree, or a repository owned by a different user (dubious ownership).
Common situations: Corrupt .git/index after a crash, worktrees whose main repo was removed, running as a different user than the repo owner (safe.directory issues), or CI checkouts with odd permissions.
Related errors
- worktree_status_failed
- (result.stderr || '').trim() || `git ${args.join(' ')} faile
- autoresearch_reset_requires_clean_worktree
- worktree_not_planned:${workerName}
- worktree_not_provisioned:${workerName}
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/71e071bc9e597753.
Report an issue: GitHub.