fix: fetch after merge in land_pr to update remote refs#117
Open
gvaish wants to merge 1 commit intomodular:mainfrom
Open
fix: fetch after merge in land_pr to update remote refs#117gvaish wants to merge 1 commit intomodular:mainfrom
gvaish wants to merge 1 commit intomodular:mainfrom
Conversation
After `gh pr merge --squash`, the remote (e.g. origin/main) has a new
squash commit, but no git fetch is performed before the final rebase of
the current branch in command_land. For single-PR stacks this means
origin/{target} is stale (land_pr fetches *before* the merge), so the
rebase is a no-op against the pre-merge ref and the current branch is
not brought up-to-date.
For multi-PR stacks the bug is masked because rebase_pr starts with its
own fetch, which incidentally updates origin/{target} in time for the
final rebase. Adding the fetch inside land_pr makes the function
self-contained and fixes the single-PR case.
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.
Problem
When
landis run with a single-PR stack, the current branch is not correctly rebased onto the post-mergeorigin/main.Root cause:
land_prdoes agit fetchbefore callinggh pr merge --squash, but not after. The squash commit lands on the remote, but the localorigin/{target}ref is still stale. The final rebase incommand_landthen runs against the pre-merge ref - a no-op - leaving the current branch behind.Why multi-PR stacks are unaffected:
rebase_prbegins with its owngit fetch --prune, which incidentally refreshesorigin/{target}in time for the finalcurrent_branchrebase. Single-PR stacks skip therebase_prloop entirely, so no fetch ever happens after the merge.Fix
Add
git fetch --pruneinsideland_pr, immediately aftergh pr merge. This makesland_prself-contained: after it returns, remote refs reflect the newly landed commit. The fetch is harmless for multi-PR stacks (a slight redundancy with the fetch at the start ofrebase_pr).Reproducer
stack-pr submit)stack-pr landgit log --oneline origin/main..HEAD— the current branch still contains the (now-landed) commit instead of being empty