Skip to content

feat: skip branches that would conflict instead of stopping mid-rebase - #20

Merged
pablospe merged 1 commit into
mainfrom
feat/conflict-precheck
Nov 15, 2026
Merged

pablospe merged 1 commit into
mainfrom
feat/conflict-precheck

Conversation

@pablospe

Copy link
Copy Markdown
Owner

wt-sync -upP from diffnav's main tried to rebase context-expand, an old one-commit WIP branch 91 commits behind main, hit conflicts in three files, and stopped there with that worktree mid-rebase. The stack that actually mattered (osc1717) never got pushed, and the same happened earlier with icon-alingment.

Before each rebase, git merge-tree --write-tree --merge-base <base> <parent> <branch> now works out the result without touching any worktree. If it would conflict, the branch and everything stacked on it are skipped with a warning naming the files, they aren't pushed, their fork-points stay as they were, and the sync carries on with the other stacks. The run still exits non-zero at the end (after pushing and pruning the rest), so wt sync && ... stops as before. The dry run shows the same thing:

Skipping context-expand: rebasing it onto main would conflict in pkg/ui/keys.go, pkg/ui/mainModel.go, pkg/ui/panes/diffviewer/diffviewer.go. Rebase it by hand (`git rebase main` in its worktree), then run wt sync.

The check looks at the end result while a rebase replays commit by commit, so now and then they can disagree. A conflict it didn't predict stops the sync exactly as it does today. If merge-tree can't run (git older than 2.40), there's no check and nothing changes.

Also from the same run: from the default branch's worktree "the current stack" means every stack, which is a lot to do implicitly when -P removes worktrees. It now says so first: On main, so syncing all 4 stacks: clipboard-error, context-expand, icon-alingment-squash, osc1717. Run from a stack's worktree to sync only that one. It doesn't print with --all or when there is only one stack.

New tests/conflict.rs: a conflicting branch and the one on top of it are skipped with their worktree untouched, a clean sibling is still rebased, the exit is non-zero, and the every-stack line shows up from main but not with --all. README's key behaviours updated.

@pablospe
pablospe merged commit b8d7bb7 into main Nov 15, 2026
2 checks passed
@pablospe
pablospe deleted the feat/conflict-precheck branch November 15, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant