Skip to content

Basic branching stacks support - #593

Closed
skarim wants to merge 9 commits into
skarim/base-retargetingfrom
skarim/branching-stacks
Closed

skarim wants to merge 9 commits into
skarim/base-retargetingfrom
skarim/branching-stacks

Conversation

@skarim

@skarim skarim commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Adds gh stack add --fork to start an independent stack from the current branch, including a branch in another stack. Each stack remains linear, with no tree-wide operations or changes to storage and recovery formats.

Functionality and user impact

  • Create separate workstreams. add --fork starts a new local stack. Mid-stack add offers to fork interactively; ordinary top-of-stack add still extends the stack.
  • Resolve shared bases correctly. When a branch is both a member and another stack's base, commands select its member stack. Head branches still cannot belong to multiple stacks.
  • Repair child history. sync and rebase handle rewritten parents and single-PR retargets using validated boundaries and the existing consent/recovery behavior.
  • Guard unsafe operations. submit checks non-default bases before pushing; modify blocks renaming, dropping, or folding locally known child-stack bases. Closed single PRs with missing bases fail with guidance.

Key areas to review

  • cmd/add.go and internal/stack/stack.go: shared creation/adoption flow, bypassing the empty-layer commit shortcut for forks, and member-first resolution.
  • cmd/utils.go: single-PR base discovery and publishing guards. Check closed-PR evidence before metadata refresh, and the distinction between local-only and deleted remote bases.
  • bottomRebaseCutoff, cmd/rebase.go, and cmd/sync.go: for parent rewrites, gate bottom-branch --onto on a valid recorded base while retaining ordinary rebase and recovery paths.
  • cmd/modify.go: reject destructive fork-point changes before ApplyPlan, without rewriting dependent stacks.

Stack created with GitHub Stacks CLI • Give Feedback 💬

Copilot AI max review requested due to automatic review settings October 26, 2026 14:42
@skarim
skarim added this pull request to stack #594 October 26, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Shared history-rewrite and publishing changes require human review, and base-handling defects remain unresolved.

4 open issues
What changed in this PR

Adds basic branching-stack support: independent linear stacks can depend on branches in other stacks without introducing tree-wide operations or changing storage and recovery formats.

Changes:

  • Adds add --fork and interactive mid-stack forking, including existing-branch adoption.
  • Prefers member-stack selection and guards destructive edits to locally known child-stack bases.
  • Adds publishing checks, child-history repair, tests, and workflow documentation.
File Description
skills/​gh-stack/​SKILL.md Documents fork commands, safeguards, and limitations.
skills/​gh-stack/​references/​stack-design.md Explains dependent-stack design and workflow.
internal/​stack/​stack.go Adds member-first stack lookup.
internal/​stack/​stack_test.go Tests lookup precedence and ambiguity.
internal/​github/​github.go Includes base names in PR details.
docs/​src/​content/​docs/​reference/​cli.md Documents fork behavior and publishing requirements.
docs/​src/​content/​docs/​guides/​workflows.md Adds a dependent-stack workflow guide.
docs/​src/​content/​docs/​faq.md Clarifies support for shared stack bases.
cmd/​worktree_utils.go Uses member-first lookup for navigation.
cmd/​view.go Updates stack selection and retarget warnings.
cmd/​view_test.go Tests shared bases and single-PR retarget display.
cmd/​utils.go Adds base discovery, validation, and rebase boundaries.
cmd/​utils_test.go Tests selection, discovery, and publication evidence.
cmd/​trunk_target_test.go Updates local-only trunk test setup.
cmd/​sync.go Integrates base evidence and rewritten-parent repair.
cmd/​sync_test.go Tests linked-parent repair and single-PR retargets.
cmd/​submit.go Adds member-first selection and base preflight.
cmd/​submit_test.go Tests publishing guards and shared-base selection.
cmd/​rebase.go Integrates base discovery and bottom-branch cutoffs.
cmd/​rebase_test.go Tests rewrite boundaries, retargets, and recovery.
cmd/​push.go Integrates member-first selection and base validation.
cmd/​push_test.go Tests shared-base selection and retarget protection.
cmd/​navigate_test.go Tests navigation through shared-base branches.
cmd/​modify.go Guards destructive edits to child-stack bases.
cmd/​modify_test.go Tests dependent-base action restrictions.
cmd/​merge.go Prefers the member stack during merge selection.
cmd/​merge_test.go Tests member-first remote-stack selection.
cmd/​init.go Points existing stack members toward add --fork.
cmd/​checkout.go Uses member-first lookup for branch targets.
cmd/​checkout_test.go Tests numeric member-branch resolution.
cmd/​add.go Implements explicit and prompted stack forks.
cmd/​add_test.go Tests fork creation, adoption, commits, and refusals.

Review effort: Max

Comment thread cmd/utils.go
Comment thread cmd/utils.go Outdated
Comment thread cmd/utils.go Outdated
Comment thread cmd/utils.go Outdated
@skarim
skarim marked this pull request as draft October 26, 2026 15:54
@skarim

skarim commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

Closing out this PR because it has gotten too large. Will break up and reopen as a stack.

@skarim skarim closed this Oct 26, 2026
@skarim
skarim removed this pull request from stack #594 October 26, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants