{"record":{"id":"882fe6a3fe4595d6","repo":"nikivdev/code","slug":"git-failed-882fe6","errorCode":null,"errorMessage":"git {} failed","messagePattern":"git (.+?) failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/home.rs","lineNumber":699,"sourceCode":"        .args([\"rev-parse\", \"--verify\", \"--quiet\", reference])\n        .current_dir(dest)\n        .stdin(Stdio::null())\n        .stdout(Stdio::null())\n        .stderr(Stdio::null())\n        .status()\n        .context(\"failed to run git\")?;\n    Ok(status.success())\n}\n\nfn git_capture(dest: &Path, args: &[&str]) -> Result<String> {\n    let output = Command::new(\"git\")\n        .args(args)\n        .current_dir(dest)\n        .stdin(Stdio::null())\n        .output()\n        .context(\"failed to run git\")?;\n    if !output.status.success() {\n        bail!(\"git {} failed\", args.join(\" \"));\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())\n}\n\nfn run_command(cmd: &str, args: &[&str], cwd: Option<&Path>) -> Result<()> {\n    let mut command = Command::new(cmd);\n    command.args(args);\n    if let Some(dir) = cwd {\n        command.current_dir(dir);\n    }\n    let status = command\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .with_context(|| format!(\"failed to run {}\", cmd))?;\n    if !status.success() {\n        bail!(\"{} failed with status {}\", cmd, status);","sourceCodeStart":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/home.rs#L681-L717","documentation":"git_capture runs a git subcommand capturing stdout (used by ensure_repo, ensure_origin_url, default_branch). If the git process exits non-zero, the helper bails with `git <args> failed`. It indicates the queried repository state could not be read (bad ref, missing remote, not a repo, etc.).","triggerScenarios":"ensure_repo / ensure_origin_url / default_branch call git_capture with args like [\"remote\",\"get-url\",\"origin\"] or branch queries and the underlying git command returns a non-zero status.","commonSituations":"Querying a repo with no origin remote configured; asking for a branch that doesn't exist; dest is not actually a git working tree; corrupt .git directory; git not handling an unusual remote config.","solutions":["Run the same git command manually in <dest> to see git's real stderr","Add the missing remote/ref the command expects (e.g. `git remote add origin <url>`)","Verify <dest> contains a valid .git directory","Re-clone the repository if .git is corrupt"],"exampleFix":"// before\ngit remote get-url origin   # -> error: no such remote 'origin'\n// after\ngit remote add origin git@github.com:owner/repo.git\ngit remote get-url origin","handlingStrategy":"try-catch","validationCode":"if !dest.join(\".git\").exists() {\n    bail!(\"{} is not a git repo; git queries will fail\", dest.display());\n}","typeGuard":null,"tryCatchPattern":"match git_capture(dest, &[\"remote\", \"get-url\", \"origin\"]) {\n    Ok(url) => use(url),\n    Err(e) if e.to_string().starts_with(\"git \") => {\n        eprintln!(\"git query failed in {} — check remotes/refs manually\", dest.display());\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure remotes/branches queried actually exist before reading them","Only call git_capture on valid working trees","Run the equivalent git command manually to see git's own stderr"],"tags":["git","process-exit","subprocess"],"backgroundTag":"git-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}