Auto-push, sync messaging, and stale-ref sync fixes#43
Merged
Conversation
When a branch already has an upstream but has unpushed local commits, `new` and `submit` now auto-push before creating the PR. This prevents the "No commits between base and head" GitHub error that forced a manual `git push` between stacked branch operations. Uses a regular push (not --force-with-lease) so non-fast-forward pushes fail safely. Also improves sync step messaging: when the old and new base are the same branch (after a parent PR merge), the message now reads "dropping already-upstream commits" instead of the confusing "from main" phrasing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Dogfooding friction fixes and two sync correctness bugs.
Auto-push unpushed commits in
new/submit, clarify sync step messaging, fix stale local main ref in sync, and fix chained sync regression for multi-branch stacks.Auto-push: When a branch already has an upstream but has unpushed local commits,
newandsubmitnow auto-push before creating the PR. This removes the manualgit pushstep that was required between stacked branch operations — without it, GitHub would reject PR creation with "No commits between base and head."Sync messaging: When old and new base are the same branch name (after a parent PR merge), the message now reads "dropping already-upstream commits" instead of the confusing "onto main (from main)."
Stale local main (Fix 3):
stck syncfetches from origin butresolve_base_ref()preferred local refs over remote refs. After a PR merges on GitHub, local main is stale, so the rebase--ontotarget and merge-base resolved to stale values — making sync a no-op. Fixed by flippingresolve_base_ref()to preferrefs/remotes/origin/<branch>.Chained sync (Fix 4): The stale-main fix overcorrects for chained syncs. When syncing a 3+ branch stack, step N rebases a branch locally but the remote ref is stale (not yet pushed). Step N+1's
--ontotarget resolves to that stale remote ref — a no-op that leaves the descendant diverged. Fixed by tracking rebased branches in aHashSetduring the sync loop and using local refs for subsequent steps.Changelist
src/gitops.rs— Addpush_branch()for safe fast-forward pushes; addresolve_onto_ref()wrapper; flipresolve_base_ref()to prefer remote refssrc/commands.rs—run_new()andrun_submit()auto-push when upstream exists but branch needs pushsrc/commands.rs— Sync step message branches onold_base_ref == new_base_refto show "dropping already-upstream commits"src/commands.rs— Sync loop usesresolve_onto_ref()for--ontotarget; tracksrebased_in_this_syncto use local ref for chained stepstests/harness/mod.rs— Add stub handlers for plaingit push origin <branch>,STCK_TEST_LOCAL_MAIN_SHA/STCK_TEST_REMOTE_MAIN_SHAenv vars, split merge-base handling for local vs remote maintests/new.rs— Add tests for auto-push and skip-push-when-up-to-datetests/submit.rs— Add test for auto-pushtests/sync.rs— Addsync_uses_remote_main_when_local_main_is_staleandsync_chained_rebase_uses_local_ref_for_previously_rebased_branch; update existing chained sync assertionsChecklist
error:QA
stck new a→ commit →stck new b→ should auto-pushaand create PR without errorstck submiton a branch with unpushed commits → should auto-push then create PRstck sync→ step message says "dropping already-upstream commits"stck sync→ child rebases onto updated main (not a no-op)stck sync→ both descendants rebase correctly; no conflicts on GitHub