{"record":{"id":"1a691c1412ecf2c0","repo":"gitbutlerapp/gitbutler","slug":"cannot-verb-rejected-1a691c","errorCode":null,"errorMessage":"Cannot {verb}: {rejected}:","messagePattern":"Cannot (.+?): (.+?):","errorType":"exception","errorClass":"ExplainedRejection","httpStatus":null,"severity":"error","filePath":"crates/but/src/utils/rejection.rs","lineNumber":119,"sourceCode":"        }\n    };\n    let (repo, ws) = (&repo, &ws);\n\n    let target_branch = match &target {\n        Target::Commit(commit) => branch_of_commit(ws, commit.commit_id, None),\n        Target::Branch(name) => Some(name.clone()),\n        Target::NewBranch(_) => None,\n    };\n\n    let changes = match explain_rejections(repo, ws, &rejected.0, target_branch.as_deref()) {\n        Ok(changes) => changes,\n        Err(other) => return other,\n    };\n\n    let mut message = format!(\"Cannot {verb}: {rejected}:\\n\");\n    // Writing to a String cannot fail.\n    let _ = write_report(&mut message, &changes, &target, target_branch.as_deref());\n    anyhow::Error::new(ExplainedRejection(message.trim_end().to_string()))\n}\n\n/// A single rejected change, enriched with the workspace dependencies that\n/// explain why it could not be applied.\nstruct RejectedChange {\n    /// The worktree-relative path of the rejected change.\n    path: BString,\n    /// The coarse reason the change was rejected.\n    reason: RejectionReason,\n    /// The hunks of this change that depend on a commit in the workspace,\n    /// together with the commit/branch they depend on.\n    ///\n    /// Empty when the rejection was not caused by a dependency, or when the\n    /// dependency could not be pinpointed to a specific hunk.\n    dependencies: Vec<HunkDependency>,\n    /// When a dependency rejection cannot be pinpointed to a hunk (adjacent\n    /// insertions, for example, do not intersect as ranges), the branches\n    /// whose workspace commits also touch this path — the likely dependency.","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/utils/rejection.rs#L101-L137","documentation":"The full-form rejection error from but's utils: the operation was rejected due to RejectedChanges, the workspace projection loaded successfully, and write_report() appended a per-path report (paths, coarse reason, and which workspace commits/branches the hunks depend on) after the 'Cannot <verb>: N rejected changes:' header. This is the explanation, not just the failure.","triggerScenarios":"Applying changes whose hunks depend on commits outside the selected target: e.g. moving/applying a commit whose parent changes are not part of the target branch set, or editing files whose workspace dependencies are not included.","commonSituations":"Cherry-applying an old commit whose context lines only exist because of a commit not being applied; ordering issues when moving commits across stacks; partial application attempts of a series.","solutions":["Read the report body: each listed path names the commit/branch the change depends on; include that dependency in the operation (apply/move it too) or apply to a target that already contains it.","Reorder operations so dependencies are applied before dependents.","If the dependency is intentionally excluded, expect the rejection and choose a different operation (e.g. apply the whole stack).","Use the listed worktree-relative paths to cross-check which files caused each hunk rejection."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.applyChanges(...);\n} catch (e) {\n  const m = String(e?.message ?? e);\n  if (/Cannot .*rejected changes:\\n/.test(m)) {\n    const report = m.split('\\n').slice(1).join('\\n');\n    showDependencyReport(report); // lists paths + the commits they depend on\n  }\n  throw e;\n}","preventionTips":["Parse the report body: each path names the commit/branch dependency to include.","Apply dependent commits in topological order (dependencies first).","When applying part of a stack, expect rejections for hunks whose context comes from excluded commits."],"tags":["rust","gitbutler","workspace","rejected-changes","report"],"backgroundTag":"operation-rejected-by-conflict","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}