submit: Refuse to overwrite commits pushed to a branch by someone else#1308
Open
ed-irl wants to merge 1 commit into
Open
submit: Refuse to overwrite commits pushed to a branch by someone else#1308ed-irl wants to merge 1 commit into
ed-irl wants to merge 1 commit into
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
This was referenced Jun 24, 2026
Lease against the commit git-spice last pushed (UpstreamLastPushedHash) instead of the local remote-tracking ref. The tracking ref advances on every fetch, silently defeating --force-with-lease and letting submit overwrite commits pushed by someone else. Submit now classifies the remote against our last-pushed baseline and refuses to overwrite when the remote has advanced (listing the foreign commits and pointing to 'gs branch sync') or diverged. Because the baseline is the remote-side last-pushed hash, this survives restacks, which only rewrite local hashes. Also carry the baseline when 'branch split' reassigns a CR to a new branch, and record it after a conflicted 'branch sync --rebase' is resumed, so a clean (non-force) submit works in both cases.
1725dbc to
7363b3a
Compare
5c06b5d to
b715e02
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gs branch submitpreviously force-pushed with a lease against the remote-tracking ref, which advances on every fetch and so could silently overwrite commits a maintainer (or anyone else) added to a branch after git-spice last pushed it.Submit now leases against the commit git-spice itself last recorded pushing. Because that baseline only changes when git-spice pushes, it survives local restacks while still catching foreign commits. Before pushing, submit classifies the remote:
gs branch sync.--forceoverrides all of these.Supporting changes:
git.ListCommitsDetailsnow also reports each commit's author email (%ae), used when listing foreign commits.gs branch sync --rebaserecords the integrated remote head as the new baseline. A conflict-interrupted sync resumes via a hidden--record-pushedcontinuation that records the baseline without re-running the rebase.branch splitcarries the last-pushed baseline onto the new branch so a later submit still has a baseline to check against.Documented in the CR guide; added test scripts covering the advanced, diverged, and force-push cases.