xai-org/grok-build · error
a merge is already in progress; resolve it or call again wit
Error message
a merge is already in progress; resolve it or call again with abort
What it means
Sync-base requires a clean merge state before starting its fetch-and-merge cycle. `merge_in_progress` checks for in-progress merge markers (MERGE_HEAD); if one exists, the call refuses with this message and instructs the caller to resolve the merge or re-invoke with `abort`.
Source
Thrown at crates/codegen/xai-grok-workspace/src/session/git.rs:3036
async fn merge_in_progress(git_root: &Path) -> Result<bool> {
Ok(
git_cli_raw(git_root, &["rev-parse", "-q", "--verify", "MERGE_HEAD"])
.await?
.0,
)
}
if abort {
let (_ok, out) = git_cli_raw_mut(git_root, &["merge", "--abort"]).await?;
anyhow::ensure!(
!merge_in_progress(git_root).await?,
"merge --abort failed: {out}"
);
return Ok(GitSyncBaseResult {
outcome: GitSyncBaseOutcome::Aborted,
});
}
ensure_on_branch(git_root, expected_branch).await?;
anyhow::ensure!(
!merge_in_progress(git_root).await?,
"a merge is already in progress; resolve it or call again with abort"
);
let dirty = git_cli(git_root, &["status", "--porcelain"]).await?;
anyhow::ensure!(
dirty.is_empty(),
"working tree is not clean; commit or discard changes before syncing the base"
);
let base = base_ref.unwrap_or("HEAD");
let (fetched, fetch_out) = git_cli_raw_mut(git_root, &["fetch", "origin", base]).await?;
anyhow::ensure!(fetched, "fetch of base ref '{base}' failed: {fetch_out}");
if git_cli_raw(
git_root,
&["merge-base", "--is-ancestor", "FETCH_HEAD", "HEAD"],
)
.await?
.0
{View on GitHub (pinned to bc7f02eddd)
Solutions
- Resolve the conflicts, `git add`, and `git commit` to finish the merge, then retry
- Re-call sync-base with `abort: true` to abort the in-progress merge automatically
- Run `git merge --abort` manually if you want to discard the merge state yourself
Example fix
// before
sync_base(&git_root, req) // merge in progress
// after
sync_base(&git_root, GitSyncBaseReq { abort: true, ..req }) // or resolve+commit first Defensive patterns
Strategy: validation
Validate before calling
fn merge_in_progress(git_root: &Path) -> bool {
git_root.join(".git/MERGE_HEAD").exists()
}
if merge_in_progress(git_root) {
// resolve or call with abort: true before proceeding
} Prevention
- After any conflicted merge, immediately resolve/commit or abort
- Call sync-base with abort:true when you know a merge may be pending
- Monitor workspace state between automated operations
When it happens
Trigger: Calling sync-base while the workspace has an unfinished merge from a previous conflicted sync-base run or a manual `git merge` that stopped on conflicts.
Common situations: A prior sync-base attempt hit conflicts and was never aborted or completed; a developer manually merged in the workspace and left conflicts unresolved.
Related errors
- workspace is on '{current}', expected '{expected}'
- merge --abort failed: {out}
- working tree is not clean; commit or discard changes before
- working tree is not clean; commit before merging to '{target
- git reset --hard {} failed: {}
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/3d1f0190ba6f0a93.
Report an issue: GitHub.