{"record":{"id":"538b0ad6ea656f10","repo":"GitoxideLabs/gitoxide","slug":"cannot-split-with-unresolved-conflicts","errorCode":null,"errorMessage":"cannot split with unresolved conflicts","messagePattern":"cannot split with unresolved conflicts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/split.rs","lineNumber":24,"sourceCode":"\npub(crate) struct Prepared {\n    pub editor: Option<gix::command::Prepare>,\n    pub document: Vec<u8>,\n    create: create::Prepared,\n    target: ObjectId,\n    source: gix::objs::Commit,\n    tree: ObjectId,\n}\n\n#[tracing::instrument(skip_all)]\npub(crate) fn prepare(mut repo: gix::Repository, todo: bool) -> Result<Prepared> {\n    let target = repo\n        .head_id()\n        .context(\"splitting requires an existing HEAD commit\")?\n        .detach();\n    let changes = load_worktree_changes_without_lines(&repo)?;\n    if changes.paths.iter().any(|change| change.kind == ChangeKind::Unmerged) {\n        anyhow::bail!(\"cannot split with unresolved conflicts\");\n    }\n    if !changes.paths.iter().any(|change| change.group == ChangeGroup::Staged)\n        || !changes.paths.iter().any(|change| change.group == ChangeGroup::Unstaged)\n    {\n        anyhow::bail!(\"splitting requires both staged and worktree changes\");\n    }\n\n    let mut source = repo\n        .find_commit(target)\n        .context(\"could not find HEAD commit\")?\n        .decode()\n        .context(\"could not decode HEAD commit\")?\n        .into_owned()\n        .context(\"could not own HEAD commit\")?;\n    let mut create = create::prepare_from(repo.clone(), Some(target), create::Source::Default, None, todo)?;\n    repo.objects.set_object_memory(std::mem::take(&mut create.objects));\n\n    let head_tree = source.tree;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/split.rs#L6-L42","documentation":"Before preparing a commit split, `prepare` loads the worktree changes and refuses to proceed if any path is in the `Unmerged` state. Splitting requires a clean, resolvable set of staged and unstaged hunks; unresolved merge conflicts would make the split ambiguous, so it is aborted up front (before the editor is launched).","triggerScenarios":"Calling `prepare` (via `splits_staged_and_worktree_changes_without_touching_files_during_preparation` or `conflicting_staged_and_worktree_hunks_abort_before_the_editor`) when `load_worktree_changes_without_lines` reports at least one change with `kind == ChangeKind::Unmerged` in the repository.","commonSituations":"A merge or rebase left conflict markers and the user runs `gix tix split` before resolving; a cherry-pick conflict is still open; index contains unmerged entries from a conflicted operation.","solutions":["Resolve the merge conflicts (`gix`/git status shows unmerged paths), then `git add` the resolved files.","Abort the in-progress merge/rebase (`git merge --abort` / `git rebase --abort`) if it should not be continued.","Run `gix tix split` again once `git status` reports no unmerged paths.","Ensure both staged and worktree changes exist afterward, since the same function also requires both groups."],"exampleFix":"// before: splitting during a conflicted merge\nrepo_split_prepare(&repo)?;\n// after: guard on unmerged state first\nif has_unmerged_paths(&repo)? {\n    anyhow::bail!(\"resolve conflicts before splitting\");\n}\nrepo_split_prepare(&repo)?;","handlingStrategy":"validation","validationCode":"fn has_unmerged_paths(repo: &gix::Repository) -> Result<bool> {\n    let changes = load_worktree_changes_without_lines(repo)?;\n    Ok(changes.paths.iter().any(|c| c.kind == ChangeKind::Unmerged))\n}","typeGuard":null,"tryCatchPattern":"match prepare(&repo) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"unresolved conflicts\") => {\n        eprintln!(\"Resolve merge conflicts (git status) before running split.\");\n        Err(e)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check `git status`/unmerged entries before starting a split; finish or abort any in-progress merge or rebase first.","Automate conflict detection (ChangeKind::Unmerged check) at the start of any stacked-edit workflow.","Remember prepare also requires both staged and unstaged changes — verify groups beforehand."],"tags":["git","merge-conflict","split","worktree","precondition"],"backgroundTag":"invalid-state-transition","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}