{"record":{"id":"9c32469cd932eba5","repo":"nikivdev/code","slug":"git-operation-in-progress-run-f-git-repair-firs","errorCode":null,"errorMessage":"Git operation in progress. Run `f git-repair` first.","messagePattern":"Git operation in progress\\. Run `f git-repair` first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/jj.rs","lineNumber":3551,"sourceCode":"        .args([\"show-ref\", \"--verify\", name])\n        .stdout(std::process::Stdio::null())\n        .stderr(std::process::Stdio::null())\n        .status()\n        .map(|s| s.success())\n        .unwrap_or(false)\n}\n\nfn ensure_git_not_busy(repo_root: &Path) -> Result<()> {\n    let git_dir = git_dir(repo_root)?;\n    let rebase = git_dir.join(\"rebase-merge\").exists() || git_dir.join(\"rebase-apply\").exists();\n    let merge = git_dir.join(\"MERGE_HEAD\").exists();\n    let cherry_pick = git_dir.join(\"CHERRY_PICK_HEAD\").exists();\n    let revert = git_dir.join(\"REVERT_HEAD\").exists();\n    let bisect = git_dir.join(\"BISECT_LOG\").exists();\n    let unmerged = git_unmerged_files(repo_root);\n\n    if rebase || merge || cherry_pick || revert || bisect || !unmerged.is_empty() {\n        bail!(\"Git operation in progress. Run `f git-repair` first.\");\n    }\n    Ok(())\n}\n\nfn git_unmerged_files(repo_root: &Path) -> Vec<String> {\n    let output = Command::new(\"git\")\n        .current_dir(repo_root)\n        .args([\"diff\", \"--name-only\", \"--diff-filter=U\"])\n        .output();\n    match output {\n        Ok(out) => String::from_utf8_lossy(&out.stdout)\n            .lines()\n            .filter(|l| !l.trim().is_empty())\n            .map(|l| l.trim().to_string())\n            .collect(),\n        Err(_) => Vec::new(),\n    }\n}","sourceCodeStart":3533,"sourceCodeEnd":3569,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/jj.rs#L3533-L3569","documentation":"ensure_git_not_busy guards destructive/reorganizing operations by checking the git dir for in-progress state: rebase, merge, cherry-pick (CHERRY_PICK_HEAD), revert (REVERT_HEAD), bisect (BISECT_LOG), or unmerged files. If any is present it bails so the wrapper doesn't run jj operations on top of a half-finished git operation.","triggerScenarios":"Running a flow command that calls ensure_git_not_busy while .git contains REBASE/MERGE/CHERRY_PICK/REVERT_HEAD or BISECT_LOG, or `git ls-files -u` (git_unmerged_files) returns unresolved conflict entries.","commonSituations":"A previous `git rebase`/`git merge` was interrupted or left mid-conflict; a cherry-pick stopped on conflicts; bisect still active; someone used raw git alongside the jj colocated repo.","solutions":["Run `f git-repair` as the message instructs, which aborts/cleans the in-progress operation.","Alternatively finish or abort manually: `git rebase --abort`, `git merge --abort`, `git cherry-pick --abort`, `git bisect reset`, then resolve unmerged files with `git status`.","Re-run your flow command once the repo is clean."],"exampleFix":"// before\nflow sync   # blocked: REBASE_HEAD present\n// after\nf git-repair\nflow sync","handlingStrategy":"validation","validationCode":"// shell: detect in-progress git state before flow commands\nGIT_DIR=$(git rev-parse --git-dir) || exit 1\nfor f in rebase-merge rebase-apply MERGE_HEAD CHERRY_PICK_HEAD REVERT_HEAD BISECT_LOG; do\n  [ -e \"$GIT_DIR/$f\" ] && { echo \"git operation in progress: $f — run f git-repair\" >&2; exit 1; }\ndone\n[ -z \"$(git ls-files -u)\" ] || { echo \"unmerged files present\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"match flow_sync() {\n  Err(e) if e.contains(\"Git operation in progress\") => {\n    run(\"f git-repair\");\n    flow_sync()\n  }\n  r => r,\n}","preventionTips":["Finish or abort raw git rebase/merge/cherry-pick sessions immediately; never leave them parked.","Prefer jj-native operations in colocated repos to avoid mixed state.","Add a pre-flight check for $GIT_DIR sentinel files in CI and scripts."],"tags":["git","repo-state","conflict","repair"],"backgroundTag":"git-operation-in-progress","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}