fix(restack): pass --update-refs to git rebase by default#119
Conversation
|
Claude finished @boneskull's task in 3m 25s —— View job Code Review
Overall this is a clean, well-reasoned implementation. The core approach — always passing the flag explicitly to override ambient
|
d9b1bd5 to
8060789
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes gh stack pass git rebase --update-refs explicitly by default (and --no-update-refs when disabled) so bookmark-style branches pointing into a rebased stack are updated predictably, regardless of a user’s rebase.updateRefs git config. It also adds a per-invocation --no-update-refs escape hatch, suppresses update-refs in worktree scenarios, and persists the resolved behavior across gh stack continue after conflicts.
Changes:
- Plumb an
updateRefsboolean through all rebase entry points and persist it in cascade state forcontinue. - Add
--no-update-refstorestack,submit, andsync, and auto-suppress update-refs in worktree-aware flows. - Add unit/e2e coverage for bookmark movement behavior, and document the Git 2.38+ requirement and new flags.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents Git 2.38+ requirement and --no-update-refs; adds a worktrees/update-refs note. |
| internal/state/state.go | Persists resolved update-refs behavior in cascade state. |
| internal/git/git.go | Adds explicit --update-refs/--no-update-refs handling to rebase wrappers. |
| internal/git/git_test.go | Adds unit tests covering bookmark movement with update-refs on/off. |
| cmd/restack.go | Resolves update-refs behavior for an operation, saves it to state, and threads it into rebases. |
| cmd/continue.go | Restores the stored update-refs behavior when resuming after conflicts. |
| cmd/submit.go | Adds --no-update-refs flag and plumbs into restack phase. |
| cmd/sync.go | Adds --no-update-refs flag and applies update-refs suppression consistently across sync flows. |
| e2e/restack_test.go | Adds e2e tests for bookmark movement with default vs --no-update-refs. |
| e2e/worktree_test.go | Adds e2e coverage for update-refs suppression in worktree scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
All rebase invocations now pass `--update-refs` or `--no-update-refs` explicitly so that the flag always overrides any ambient `rebase.updateRefs` git config setting. - Untracked bookmark branches pointing into the rebased chain are kept in sync automatically (default behaviour via `--update-refs`). - Adds `--no-update-refs` flag to `restack`, `submit`, and `sync` as a per-invocation escape hatch for users who want to preserve bookmark branches. - When linked worktrees are detected (`--worktrees` with at least one branch actually checked out elsewhere), `--update-refs` is suppressed automatically. Git silently skips refs checked out in other worktrees rather than refusing, which would corrupt the stack with no warning. - The resolved setting is persisted to cascade state so `gh stack continue` resumes remaining branches with the same behaviour after a conflict. - Adds a cached Git version check (requires 2.38+) with a clear error message when the requirement is not met. Closes #112.
8060789 to
e7cbcf1
Compare
All rebase invocations now pass
--update-refsexplicitly so thatuntracked bookmark branches pointing into the stack are kept in sync
automatically. The flag is always passed explicitly (either
--update-refsor--no-update-refs) to override any ambientrebase.updateRefsgit config setting.--no-update-refsflag torestack,submit, andsyncasa per-invocation escape hatch for users who want to preserve bookmark
branches.
--worktreesmode automatically suppresses--update-refsbecausegit silently skips refs checked out in other worktrees, which would
corrupt the stack with no warning (see
docs/update-refs.md).gh stack continueresumes remaining branches with the same behavior after aconflict.
Closes #112.