Skip to content

stck sync fails when parent branch was squash-merged #47

@Reinand

Description

@Reinand

Problem

When a parent branch in a stack is squash-merged into main, stck sync cannot rebase the remaining stack. Each original commit from the squash-merged branch conflicts with what's already in main, because git doesn't recognize them as already-upstream.

Steps to reproduce

  1. Have a stack: main <- A <- B <- C
  2. Branch A has commits a1, a2, a3
  3. Squash-merge A into main (creates single commit a_squashed)
  4. Retarget B to main
  5. Run stck sync
  6. Result: conflict on every commit from A (a1, a2, a3) because git doesn't know they're already in main

Workaround

We had to manually identify the fork point (last commit unique to the parent branch) and use git rebase --onto per branch:

git rebase --onto origin/main <old-parent-tip> <branch>

This had to be done for each branch in the stack, finding the correct fork point each time.

Suggestion

stck sync could detect squash-merged parents by comparing the tree/diff rather than commit hashes. Alternatively, it could use git rebase --onto with the merge-base of the old parent, skipping commits that are already represented in the target.

GitHub's "Squash and merge" is the most common merge strategy for PRs, so this is likely the primary scenario for stacked PR workflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions