Skip to content

feat!: mark merged stack branches - #100

Open
lettertwo wants to merge 4 commits into
mainfrom
stack-merged-marker
Open

lettertwo wants to merge 4 commits into
mainfrom
stack-merged-marker

Conversation

@lettertwo

@lettertwo lettertwo commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Background

gh stack sync never removes a merged branch from the gh-stack metadata file. It sets pullRequest.merged: true on the row and keeps the row so its own rebase and display logic keep working, and its --prune runs git branch -D on the local branch. That delete fails when a worktree has the branch checked out, which is the normal git-workon case.

The reader only carried branch and base from each row, so StackMetadata had no notion of merged. The only filter in metadata::enumerate is the ghost check, which never fires because the branch ref still exists. After a stack merges bottom-up, workon list and find keep showing the merged branch as an ordinary live stack member, with the rest of the stack still nested under it.

Change

This PR reads pullRequest.merged into BranchMetadata.merged and carries the merged set on Stack as a new merged: HashSet<String> field. The field is a breaking addition to the published workon crate, on the same ! precedent as number.

  • enumerate drops merged rows the way it drops ghosts, but first reparents each surviving branch past every merged ancestor. Sync merges a stack bottom-up, so without that step a merged bottom branch would take the whole remaining stack down with it. current keeps merged rows, since routing still needs them visible.
  • The tree builder in display.rs drops a merged branch that has no worktree and splices its live children onto its parent. A merged branch that does have a worktree still renders, with a dim merged suffix in the same slot and style as the #N stack-number suffix.
  • list --json gains an additive per-stack "merged" array beside parents and checkouts.
  • The fixture gains gh_stack_merged_branch so tests can write a merged pullRequest on a gh-stack row.

Graphite has no observable merged state in either .graphite_metadata.db or the refs/branch-metadata/* blobs, so merged is always false there. The gap is recorded in ADR-028 under Consequences.

@lettertwo
lettertwo added this pull request to stack #103 September 16, 2026 14:36
@lettertwo lettertwo changed the title feat: indicate merged changesets in stacks feat!: read gh-stack merged state and mark merged stack branches Sep 16, 2026
@lettertwo lettertwo changed the title feat!: read gh-stack merged state and mark merged stack branches feat!: mark merged stack branches Sep 16, 2026
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.

1 participant