Skip to content

feat: add --skip-conflicts to restack commands - #1235

Open
mvanhorn wants to merge 4 commits into
abhinav:mainfrom
mvanhorn:feat/116-restack-skip-conflicts
Open

mvanhorn wants to merge 4 commits into
abhinav:mainfrom
mvanhorn:feat/116-restack-skip-conflicts

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a --skip-conflicts flag to all restack commands (gs repo restack, gs stack restack, gs upstack restack, gs downstack restack, gs branch restack). When set, any branch that cannot be rebased cleanly due to a conflict is aborted and skipped (along with its upstack descendants) and logged, instead of dropping into the interactive conflict-resolution flow. The rest of the branches still restack, and the command exits successfully with a summary of how many branches were skipped.

Why this matters (#116)

Today a single conflicting branch blocks an entire multi-branch restack such as gs repo restack. For stale stacks the user does not intend to work on, this forces them into a rescue/continue cycle just to get the rest of their branches restacked. As raised in #116, it is useful to opt into skipping conflicting branches and logging the un-rebased stacks (prior art: Graphite). The flag is off by default, so existing behavior is unchanged.

Changes

  • restack.Request gains a SkipConflicts field. In the restack loop, a RebaseInterruptConflict is aborted and skipped (warning <branch>: conflict, skipping) when the flag is set; descendants of a skipped branch are skipped consistently, and a final Skipped N branch(es) due to conflicts summary is logged.
  • Deliberate (non-conflict) rebase interruptions still route to the existing rescue flow, regardless of the flag.
  • After skipping conflicts, the starting branch is checked out at the end so the user is never left stranded on a conflicting branch (this also covers the all-conflicts case where nothing restacked).
  • The flag is plumbed through the RestackBranch/RestackStack/RestackUpstack/RestackDownstack handler entrypoints (via small per-command options structs) and the corresponding CLI commands.
  • Added a changelog entry, regenerated the CLI reference and command help fixtures.

Testing

  • New unit tests in internal/handler/restack covering: a conflicting branch plus its upstack being skipped while an independent branch restacks; the all-conflicts case still returning to the starting branch; and a deliberate interrupt still routing to rescue.
  • New test script testdata/script/restack_skip_conflicts.txt exercising gs repo restack --skip-conflicts end to end (conflicting stack skipped, clean branch restacked, working tree clean, back on the starting branch, exit 0).
  • go build ./..., go vet, the affected package tests, the command help fixtures, and the new test script all pass.

Fixes #116

AI was used for assistance.

mvanhorn and others added 3 commits June 10, 2026 19:07
The rebase onto upstream's request-based restack API introduced
restack.BranchRequest usage in merge/handler_test.go without the
corresponding import, so the package failed to compile.

All internal/handler test packages pass and go build ./... is clean.

This branch has not been deployed

No deployments
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.

restack: optional conflict resolution

1 participant