Skip to content

daemon: has_skip heuristic misses skip-then-continue sequences in cherry-pick attribution #982

@svarlamov

Description

@svarlamov

Summary

The has_skip check in strict_cherry_pick_mappings_from_command (src/daemon.rs:2773) only inspects the final completing command's invoked_args for --skip. This correctly handles the case where cherry-pick --skip itself is the final command that auto-applies remaining commits. However, when a skip occurs mid-sequence and later commits also conflict, the final completing command is cherry-pick --continue — so has_skip is false.

Impact

With has_skip = false, min_count is set to source_commits.len(), and the loop only tries the full count. Since some commits were skipped, fewer new commits exist, resolve_linear_head_commit_chain_for_worktree fails, and the function returns an error — losing attribution for all cherry-picked commits in the sequence.

Repro scenario

git cherry-pick A B C   # A conflicts
git cherry-pick --skip  # skip A; B also conflicts
git cherry-pick --continue  # complete with B and C applied (only 2 new commits, not 3)

At the --continue step: cmd.invoked_args contains --continue, not --skip, so has_skip = false, min_count = 3, but only 2 new commits exist → chain reconstruction fails.

Root cause

src/daemon.rs:2773:

let has_skip = cmd.invoked_args.iter().any(|arg| arg == "--skip");
let min_count = if has_skip { 1 } else { source_commits.len() };

The heuristic only covers the final-command case. Skips that occur earlier in the sequence are not tracked.

Suggested fix

Track skipped commits in the daemon's cherry-pick pending state (alongside pending_cherry_pick_sources). When a --skip is observed, record it so that subsequent --continue commands know to widen the count range. This avoids relying on the final command's argv entirely.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions