From b7d59e8e1fe1c38018b60cd683a2d6f56b18a114 Mon Sep 17 00:00:00 2001 From: Gaurav Vaish Date: Wed, 18 Feb 2026 11:50:33 -0800 Subject: [PATCH] Fetch after merge in land_pr to update remote refs 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. --- src/stack_pr/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) mode change 100755 => 100644 src/stack_pr/cli.py diff --git a/src/stack_pr/cli.py b/src/stack_pr/cli.py old mode 100755 new mode 100644 index cf52324..13d495a --- a/src/stack_pr/cli.py +++ b/src/stack_pr/cli.py @@ -1220,6 +1220,12 @@ def land_pr(e: StackEntry, remote: str, target: str, *, verbose: bool) -> None: input=pr_body.encode(), quiet=not verbose, ) + # Fetch after the merge so that remote refs (e.g. origin/main) reflect the + # newly landed commit before any subsequent rebase operations. Without + # this, single-PR stacks leave origin/{target} stale: land_pr fetches + # *before* the merge, so the squash commit is invisible to the final + # rebase of the current branch in command_land. + run_shell_command(["git", "fetch", "--prune", remote], quiet=not verbose) def delete_local_branches(st: list[StackEntry], *, verbose: bool) -> None: