Skip to content

Submit a stack from whichever worktree has it checked out - #50

Merged
DomBlack merged 1 commit into
dom/new-stack-in-worktree-filefrom
dom/adopt-stack-into-worktree
Oct 16, 2026
Merged

DomBlack merged 1 commit into
dom/new-stack-in-worktree-filefrom
dom/adopt-stack-into-worktree

Conversation

@DomBlack

@DomBlack DomBlack commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Fixing where new stacks get written (the PR below) doesn't help a stack that's already in another worktree's file. A stack started in the main checkout and then checked out in a worktree still can't be submitted or added to from there, and neither can the ones an older git-stack already put in the wrong file.

So before running gh stack submit or add, we find the file holding the current branch's stack and, if it isn't this worktree's, move that stack's record over as it is (PR records, the stack id and anything we don't model all come along). Check the branch out somewhere else and submit there and it just moves again.

We only ask git for the current branch when some stack actually lives in another worktree's file, so the usual case doesn't do any extra work.

@DomBlack
DomBlack added this pull request to stack #51 October 16, 2026 12:17
@DomBlack DomBlack added the bug Something isn't working label Oct 16, 2026
gh stack only reads the stack file in the git dir it runs in, so a stack started in the main checkout couldn't be submitted (or added to) from a worktree that had its branch checked out: gh stack said the branch wasn't in a stack. The same went for stacks an older git-stack had already put in the main checkout's file from a worktree, like the one I hit with init.

So before running gh stack submit or add, we now find the file holding the current branch's stack and, if it isn't this worktree's, move that stack's record over as it is (PR records, ids and anything else in it included). Check the branch out somewhere else and submit from there and it moves again. Nothing is read from git unless some stack actually lives in another worktree's file, so the usual case costs nothing extra.
@DomBlack
DomBlack force-pushed the dom/adopt-stack-into-worktree branch from a42b2d6 to 60c8414 Compare October 16, 2026 12:18
@DomBlack
DomBlack merged commit ff3b649 into main Oct 16, 2026
5 checks passed
@DomBlack
DomBlack deleted the dom/adopt-stack-into-worktree branch October 16, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant