{"record":{"id":"e0978d2b3f06b2d2","repo":"Egonex-AI/Understand-Anything","slug":"git-args-0-failed-result-stderr-result-e","errorCode":null,"errorMessage":"git ${args[0]} failed: ${result.stderr || result.error || result.status}","messagePattern":"git (.+?) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/validate-incremental-symbols.mjs","lineNumber":288,"sourceCode":"        }\n      }\n    }\n    missing.push(entry);\n  }\n  return {\n    filePath: previous.filePath,\n    beforeCount: previous.nodes.length,\n    afterCount: current.nodes.length,\n    beforeSymbolCount: oldSymbols.length,\n    afterSymbolCount: newSymbols.length,\n    missing,\n    replacements,\n  };\n}\n\nexport function git(root, args) {\n  const result = spawnSync('git', args, { cwd: root, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });\n  if (result.status !== 0) throw new Error(`git ${args[0]} failed: ${result.stderr || result.error || result.status}`);\n  return result.stdout;\n}\n\nexport function loadSymbolContext(projectRoot, intermediateDir) {\n  const plan = readJson(join(intermediateDir, 'incremental-plan.json'));\n  const baseline = readJson(join(intermediateDir, 'incremental-symbol-baseline.json'));\n  if (baseline.version !== 1 || baseline.baseCommit !== plan.baseCommit || baseline.headCommit !== plan.headCommit\n    || !Array.isArray(baseline.files)) throw new Error('Symbol baseline does not match the incremental plan');\n  const paths = baseline.files.map(file => file.filePath).sort();\n  if (JSON.stringify(paths) !== JSON.stringify([...plan.filesToReanalyze].sort())\n    || paths.some(path => !normalizePath(path) || (plan.deletedFiles ?? []).includes(path))\n    || new Set(paths).size !== paths.length) {\n    throw new Error('Symbol baseline file inventory does not match the incremental plan');\n  }\n  if (git(projectRoot, ['rev-parse', 'HEAD']).trim() !== plan.headCommit) {\n    throw new Error('HEAD changed since prepare; baseline not advanced');\n  }\n  // Check every analyzer input, even if all IDs survive and parsing is skipped.","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/validate-incremental-symbols.mjs#L270-L306","documentation":"The `git()` helper in validate-incremental-symbols.mjs runs a git command via spawnSync in the project root and throws whenever git exits with a non-zero status. The thrown message includes the failing subcommand and git's stderr (or the error object / exit status when stderr is empty). It exists because incremental symbol validation depends on git state (rev-parse HEAD, git diff --quiet) and cannot proceed safely if any git invocation fails.","triggerScenarios":"Any call to `git(root, args)` where the spawned `git <args[0]>` exits non-zero, e.g. `git(root, ['rev-parse','HEAD'])` when root is not inside a git worktree, or `git(root, ['diff','--quiet',headCommit,'--',...paths])` when headCommit does not exist locally.","commonSituations":"Running the validator outside a git repository or in a worktree with a broken .git; referencing a commit hash that was garbage-collected or never fetched; shallow clones lacking the base commit; git not installed or not on PATH (result.error set, status null); corrupt index requiring `git reset`.","solutions":["Read the stderr in the message and fix the underlying git failure (e.g. `git fetch` the missing commit, `git status` to repair the index).","Verify you are running the script from inside a valid git worktree: `git -C <root> rev-parse --is-inside-work-tree`.","Ensure git is installed and on PATH (`git --version`).","For shallow clones, run `git fetch --unshallow` (or deepen) so the plan's base/head commits exist locally.","If the repo is corrupt, re-clone or run `git fsck` to diagnose."],"exampleFix":"// before: running validator in a non-repo directory\nnode validate-incremental-symbols.mjs /tmp/not-a-repo\n// Error: git rev-parse failed: fatal: not a git repository...\n\n// after: run inside the project git root\ncd /path/to/project && node validate-incremental-symbols.mjs .","handlingStrategy":"try-catch","validationCode":"import { execFileSync } from 'node:child_process';\nfunction assertGitRepo(root) {\n  execFileSync('git', ['-C', root, 'rev-parse', '--is-inside-work-tree'], { stdio: 'ignore' });\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateIncrementalSymbols({ projectRoot, intermediateDir });\n} catch (err) {\n  if (String(err.message).startsWith('git ')) {\n    console.error('git operation failed; check repo state:', err.message);\n  } else throw err;\n}","preventionTips":["Run the validator only inside a valid git worktree (assert with rev-parse first).","Ensure git is installed and on PATH.","Fetch/unshallow clones so planned commits exist locally.","Keep the repo index healthy; run git fsck when commands start failing."],"tags":["git","process-spawn","incremental-analysis"],"backgroundTag":"git-command-failed","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}