{"record":{"id":"241adaec65217ab2","repo":"GitoxideLabs/gitoxide","slug":"rewording-the-commit-would-cause-a-merge-conflict","errorCode":null,"errorMessage":"rewording the commit would cause a merge conflict","messagePattern":"rewording the commit would cause a merge conflict","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/reword.rs","lineNumber":43,"sourceCode":"\npub(crate) struct Outcome {\n    pub target: gix::ObjectId,\n    pub commit: Option<gix::ObjectId>,\n    pub enrichment: Option<crate::enrich::Enrichment>,\n    pub ref_rewrites: Vec<rebase::RefRewrite>,\n    pub ref_changes: Vec<super::undo::RefChange>,\n}\n\npub(crate) enum Perform {\n    Complete(Outcome),\n    Conflict(rebase::Conflict),\n}\n\nimpl Perform {\n    fn complete(self) -> Result<Outcome> {\n        match self {\n            Perform::Complete(outcome) => Ok(outcome),\n            Perform::Conflict(_) => anyhow::bail!(\"rewording the commit would cause a merge conflict\"),\n        }\n    }\n}\n\npub(crate) fn relocate_after_editor(\n    repo: &gix::Repository,\n    revisions: &[std::ffi::OsString],\n    hidden_revisions: &[std::ffi::OsString],\n    change_id: gix::hash::ChangeId,\n) -> Result<(crate::history::HistoryGraph, gix::ObjectId)> {\n    let graph = super::loaded_view_graph_with_hidden(repo, revisions, hidden_revisions)?;\n    let mut matches = Vec::new();\n    for id in graph.stored_commit_ids() {\n        if crate::change_id::for_commit(repo, id)? == change_id {\n            matches.push(id);\n        }\n    }\n    match matches.as_slice() {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/reword.rs#L25-L61","documentation":"`Perform::complete` unwraps the result of a reword operation: a `Perform::Complete` yields the outcome, but a `Perform::Conflict` means the rebase machinery hit a merge conflict while rewording, which this API does not support interactively. The library converts that into an error stating that rewording would cause a merge conflict.","triggerScenarios":"Calling reword (via `complete`) on a commit whose changes conflict with the surrounding history — typically rewording a commit while `relocate_after_editor` must replay descendants, and those replays clash with the reworded content.","commonSituations":"Rewording a commit whose message is referenced by patches of later commits is usually fine, but content-level conflicts arise when descendants touch the same lines and the reword path also rewrites content; rebased histories with overlapping edits; interactive edits of deep history.","solutions":["Abort the reword and resolve conflicts manually with an interactive rebase (`git rebase -i <base>`), editing the message there and resolving conflicts as they appear.","Reword only the tip commit (no descendants to replay) to avoid the conflict path.","Use `git commit --amend` after checking out the commit, then rebase descendants with conflict resolution."],"exampleFix":"// before: non-interactive reword that hits conflict\nlet outcome = perform.complete()?; // bails with conflict message\n// after: shell-based resolution\n// git rebase -i <base>   # mark the commit as `reword`, resolve conflicts as prompted","handlingStrategy":"try-catch","validationCode":"// pre-check that rewording the tip only (no descendants) avoids replay conflicts\nlet head = repo.head_id()?.detach();\nif commit_id != head {\n    eprintln!(\"rewording non-tip commits may conflict; prefer git rebase -i\");\n}","typeGuard":null,"tryCatchPattern":"match reword_perform.complete() {\n    Err(e) if e.to_string().contains(\"merge conflict\") => {\n        eprintln!(\"fall back to interactive rebase: git rebase -i <base>, mark the commit as reword\");\n    }\n    other => other?,\n}","preventionTips":["Reword tip commits non-interactively; use `git rebase -i` for deeper history.","Avoid interleaved content edits between the reworded commit and its descendants.","Resolve pending conflicts in the working tree before any reword/rebase operation."],"tags":["git","rebase","merge-conflict"],"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-16T04:17:20.429Z"}