(bug fix): use explicit force-with-lease refs for stack sync#1
Open
ravi-pplx wants to merge 1 commit into
Open
(bug fix): use explicit force-with-lease refs for stack sync#1ravi-pplx wants to merge 1 commit into
ravi-pplx wants to merge 1 commit into
Conversation
Build per-branch force-with-lease arguments so pushes do not rely on Git inferring the destination branch from local branch config.
During `gh stack sync`, the relevant command flow is still fetch/rebase/push. For a branch `b1`, the old push shape was:
```console
git fetch origin b1
git rebase ...
git push origin --force-with-lease --atomic b1
```
This can fail at the final push when Git cannot derive the expected value for `refs/heads/b1` from the same local tracking ref that the fetch updated.
The fixed shape resolves the fetched tracking ref explicitly and pins the destination ref in both the lease and refspec:
```console
git fetch origin b1
git rebase ...
git rev-parse --verify --quiet refs/remotes/origin/b1
git push origin --force-with-lease=refs/heads/b1:<fetched-sha> --atomic b1:refs/heads/b1
```
If someone updates `b1` after the fetch, the final push fails because `refs/heads/b1` no longer equals `<fetched-sha>`. If `b1` had no tracking ref, the lease is empty, so the push fails if someone created `refs/heads/b1` first.
Update fake-git coverage for tracked branches, missing tracking refs, and the non-force path skipping lease lookup. The fake `git` is built as a small Go executable so `exec.LookPath("git")` finds it on Windows as `git.exe`, instead of relying on an extensionless POSIX script.
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.
Build per-branch force-with-lease arguments so pushes do not rely on Git inferring the destination branch from local branch config.
During
gh stack sync, the relevant command flow is still fetch/rebase/push. For a branchb1, the old push shape was:This can fail at the final push when Git cannot derive the expected value for
refs/heads/b1from the same local tracking ref that the fetch updated.The fixed shape resolves the fetched tracking ref explicitly and pins the destination ref in both the lease and refspec:
If someone updates
b1after the fetch, the final push fails becauserefs/heads/b1no longer equals<fetched-sha>. Ifb1had no tracking ref, the lease is empty, so the push fails if someone createdrefs/heads/b1first.Update fake-git coverage for tracked branches, missing tracking refs, and the non-force path skipping lease lookup. The fake
gitis built as a small Go executable soexec.LookPath("git")finds it on Windows asgit.exe, instead of relying on an extensionless POSIX script.