{"record":{"id":"fecf0583bfb2f392","repo":"gitbutlerapp/gitbutler","slug":"no-commits-were-provided-to-cherry-pick","errorCode":null,"errorMessage":"No commits were provided to cherry-pick","messagePattern":"No commits were provided to cherry-pick","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/commit/cherry_pick.rs","lineNumber":34,"sourceCode":"/// Sources are read from the object database, so they may live anywhere in the repository,\n/// including on branches that aren't part of the workspace. Duplicates are dropped, keeping the\n/// first occurrence, and the rest are applied in the order given rather than reordered, like\n/// `git cherry-pick`: the first source lands at `side` of `relative_to`, and each later one\n/// directly above the one before it.\n/// Child commits, and the target commit, if applicable, are rebased atop the cherry-picked commits.\npub fn cherry_pick_commits<'ws, 'meta, M: RefMetadata>(\n    mut editor: Editor<'ws, 'meta, M>,\n    source_commits: impl IntoIterator<Item = gix::ObjectId>,\n    relative_to: RelativeTo,\n    side: InsertSide,\n) -> anyhow::Result<(SuccessfulRebase<'ws, 'meta, M>, Vec<Selector>)> {\n    let mut seen = HashSet::new();\n    let sources = source_commits\n        .into_iter()\n        .filter(|id| seen.insert(*id))\n        .collect::<Vec<_>>();\n    if sources.is_empty() {\n        bail!(\"No commits were provided to cherry-pick\")\n    }\n    if matches!(\n        (&relative_to, side),\n        (RelativeTo::Reference(_), InsertSide::Above)\n    ) {\n        bail!(\"Cannot cherry-pick above a reference\")\n    }\n\n    let target = relative_to.to_selector(&editor)?;\n\n    let mut inserted_selectors = Vec::with_capacity(sources.len());\n    let mut previous_selector = None;\n    for source in sources {\n        // Give the copy its own change ID, retaining all other metadata.\n        let mut template = editor.find_commit(source)?;\n        let mut headers = Headers::try_from_commit(&template.inner).unwrap_or_default();\n        headers.change_id = Headers::from_config(&editor.repo().config_snapshot()).change_id;\n        headers.set_in_commit(&mut template.inner);","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/commit/cherry_pick.rs#L16-L52","documentation":"Input validation at the top of cherry_pick_commits: the caller passed an empty commit list, so there is nothing to cherry-pick. This is a programming/caller error rather than a user-facing state; the API requires at least one source commit to apply at the target position.","triggerScenarios":"Calling `cherry_pick_commits` with an empty `source_commits` iterator, or with a list containing only duplicate ids that collapse to nothing is impossible (duplicates still yield one) — effectively only an empty input triggers it.","commonSituations":"Callers filtering commit lists before the call and passing an empty Vec; UI sending no selection; upstream query returning no commits.","solutions":["Ensure the caller collects at least one commit id before invoking cherry-pick","Validate the input list is non-empty in the calling layer and surface a friendlier message","Check that the source selection/branch actually contains commits"],"exampleFix":"// before\ncherry_pick_commits(repo, meta, selected, ...)?;\n// after\nanyhow::ensure!(!selected.is_empty(), \"select at least one commit to cherry-pick\");\ncherry_pick_commits(repo, meta, selected, ...)?;","handlingStrategy":"validation","validationCode":"anyhow::ensure!(!source_commits.is_empty(), \"select at least one commit to cherry-pick\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate selection lists at the UI/CLI boundary","Deduplicate and check emptiness before passing commit ids to workspace APIs"],"tags":["cherry-pick","validation","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}