gitbutlerapp/gitbutler · error
No commits were provided to cherry-pick
Error message
No commits were provided to cherry-pick
What it means
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.
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
Example fix
// before cherry_pick_commits(repo, meta, selected, ...)?; // after anyhow::ensure!(!selected.is_empty(), "select at least one commit to cherry-pick"); cherry_pick_commits(repo, meta, selected, ...)?;
Defensive patterns
Strategy: validation
Validate before calling
anyhow::ensure!(!source_commits.is_empty(), "select at least one commit to cherry-pick");
Prevention
- Validate selection lists at the UI/CLI boundary
- Deduplicate and check emptiness before passing commit ids to workspace APIs
When it happens
Trigger: 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.
Common situations: Callers filtering commit lists before the call and passing an empty Vec; UI sending no selection; upstream query returning no commits.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Aborting due to empty
- Need at least 2 commits to squash
- No changes were provided to uncommit
- no commit IDs provided for discard
- no commit IDs provided for discard
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/fecf0583bfb2f392.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/commit/cherry_pick.rs:34
/// Sources are read from the object database, so they may live anywhere in the repository,
/// including on branches that aren't part of the workspace. Duplicates are dropped, keeping the
/// first occurrence, and the rest are applied in the order given rather than reordered, like
/// `git cherry-pick`: the first source lands at `side` of `relative_to`, and each later one
/// directly above the one before it.
/// Child commits, and the target commit, if applicable, are rebased atop the cherry-picked commits.
pub fn cherry_pick_commits<'ws, 'meta, M: RefMetadata>(
mut editor: Editor<'ws, 'meta, M>,
source_commits: impl IntoIterator<Item = gix::ObjectId>,
relative_to: RelativeTo,
side: InsertSide,
) -> anyhow::Result<(SuccessfulRebase<'ws, 'meta, M>, Vec<Selector>)> {
let mut seen = HashSet::new();
let sources = source_commits
.into_iter()
.filter(|id| seen.insert(*id))
.collect::<Vec<_>>();
if sources.is_empty() {
bail!("No commits were provided to cherry-pick")
}
if matches!(
(&relative_to, side),
(RelativeTo::Reference(_), InsertSide::Above)
) {
bail!("Cannot cherry-pick above a reference")
}
let target = relative_to.to_selector(&editor)?;
let mut inserted_selectors = Vec::with_capacity(sources.len());
let mut previous_selector = None;
for source in sources {
// Give the copy its own change ID, retaining all other metadata.
let mut template = editor.find_commit(source)?;
let mut headers = Headers::try_from_commit(&template.inner).unwrap_or_default();
headers.change_id = Headers::from_config(&editor.repo().config_snapshot()).change_id;
headers.set_in_commit(&mut template.inner);View on GitHub (pinned to 58e5313667)