Skip to content

send pull.stacked option on force push - #562

Open
ktravers wants to merge 3 commits into
mainfrom
ktravers/rebase-with-push-option
Open

ktravers wants to merge 3 commits into
mainfrom
ktravers/rebase-with-push-option

Conversation

@ktravers

@ktravers ktravers commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

This PR updates git.Push to send a push options argument (-o pull.stacked) on forced push only. Consumers can then read that argument as a signal that the ref update belongs to a stacked pull request and handle appropriately. Specifically, this will support retaining approving reviews on stacked pull requests after a rebase that doesn't change the diff (before and after diffs are "tree same").

@ktravers ktravers self-assigned this Oct 17, 2026
@ktravers ktravers changed the title send pull.stacked option on push send pull.stacked option on force push Oct 20, 2026
@ktravers ktravers added go Pull requests that update go code topic: cli - submit `gh stack submit`: remote/SSH handling, config flags, draft PRs, and submit UX or failures. topic: cli - rebase `gh stack rebase` behavior and bugs: --upstack, interactive/fixup, hangs, squash-merge handling. topic: cli - push `gh stack push`: atomic-push bug, pre-commit/pre-push hooks, --no-verify, per-branch control. topic: cli - sync `gh stack sync`: pruning, base updates after merge, trunk migration, squash-merge replays. topic: approvals Rebasing a stack dismisses downstream approvals, forcing re-review. labels Oct 20, 2026
@ktravers
ktravers marked this pull request as ready for review October 20, 2026 16:27
@ktravers
ktravers requested a review from skarim as a code owner October 20, 2026 16:27
@ktravers
ktravers requested review from Lukeghenco, francisfuzz, georgebrock and wiseemily88 and a balanced review from Copilot October 20, 2026 16:27

@skarim skarim left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! applying the flag on all force pushes (but not non-force pushes) makes sense to me ✅

Comment thread internal/git/gitops.go

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Force pushes discard configured push options, and localized Git errors bypass the fallback.

2 open issues
What changed in this PR

Adds a stacked-PR signal to force pushes, supporting approval retention after rebases that leave the PR diff unchanged.

Changes:

  • Sends pull.stacked on force pushes, with an unsupported-remote fallback.
  • Adds push-option integration tests and updates rebase fixtures.
File Description
internal/​git/​gitops.go Adds the push option and fallback.
internal/​git/​gitops_test.go Tests option delivery and unsupported remotes.
cmd/​rebase_test.go Enables push options in test remotes.

Review effort: Balanced

Comment thread internal/git/gitops.go
}
// Send the "pull.stacked" push option on force pushes, falling back to a
// plain push for remotes that don't support push options.
withOpt := append([]string{"push", "-o", "pull.stacked"}, args[1:]...)
Comment thread internal/git/gitops.go
// Send the "pull.stacked" push option on force pushes, falling back to a
// plain push for remotes that don't support push options.
withOpt := append([]string{"push", "-o", "pull.stacked"}, args[1:]...)
err := d.runSilent(withOpt...)

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

go Pull requests that update go code topic: approvals Rebasing a stack dismisses downstream approvals, forcing re-review. topic: cli - push `gh stack push`: atomic-push bug, pre-commit/pre-push hooks, --no-verify, per-branch control. topic: cli - rebase `gh stack rebase` behavior and bugs: --upstack, interactive/fixup, hangs, squash-merge handling. topic: cli - submit `gh stack submit`: remote/SSH handling, config flags, draft PRs, and submit UX or failures. topic: cli - sync `gh stack sync`: pruning, base updates after merge, trunk migration, squash-merge replays.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants