Skip to main content

Module stack

Module stack 

Source
Expand description

Stack metadata: the branch.<name>.stkParent/stkBase annotations and the structural queries built on them. Navigation lives in [nav], the rebase engine in restack.

Functions§

abort_restack
adopt_branch
base_for_branch
behind_parent_hint
A restack nudge when branch is missing commits from its parent’s tip. Local-only; a missing parent yields nothing.
branch_and_descendants
branch_parents
(branch, parent) pairs for the branches that have a stack parent; branches without one are skipped.
checkout_bottom
Check out the bottom of the current stack: the branch just above the trunk. From the trunk itself, a single stacked child is unambiguous.
checkout_child
checkout_parent
checkout_top
Check out the leaf of the current stack, following single children. A fork is ambiguous, like up without a branch.
children_for_branch
clear_renamed_from
Drop the rename marker once its review has been handled.
continue_restack
create_branch
detach_branch
insert_branch
Insert a new empty branch directly above the current one, moving the current branch’s children onto it. The new branch shares the current tip, so descendants stay correctly based; commit to it, then restack to replay them. Any uncommitted changes ride onto the new branch, like new.
parent_for_branch
path_from_root
The stack path from the bottom up to (and including) branch, parent-first; descendants above it are left out.
prepend_branch
Insert a new empty branch directly below the current one, moving the current branch onto it. Branches from the current branch’s parent, so it requires a clean worktree. Commit to it, then restack.
print_all_stacks
Print every stack, not just the current one: the trunk-rooted forest with a single trunk line at the bottom, and each rootless fragment as its own tree above it. The branch you are on is marked wherever it appears.
print_children
print_parent
print_stack
record_base
Record the fork point between a branch and its parent (best effort; e.g. unrelated histories have no merge base, which is not an error here).
rename_branch
Rename a branch and keep the stack intact. Git moves the branch’s own metadata with the rename; children pointing at the old name are retargeted here.
renamed_from
The branch branch was renamed from, if a replaced review is still pending.
restack
set_base_for_branch
set_parent_for_branch
set_renamed_from
Record that branch is the rename of old, whose open review the next submit should replace and close.
snapshot
Record the current stack so undo can restore it. The label names the operation being undone. No-ops after the first call in a process, and is best effort: a snapshot failure never blocks the command itself.
stack_line
Every branch in the stack containing branch, parent-first: the line from the stack bottom up through branch, plus everything above it. Sibling stacks that share only the trunk are left out - they branch off the trunk separately, not through branch. The trunk itself is excluded; an unanchored root stays in (path_from_root keeps it).
stack_root
The root of the stack containing branch (the base everything sits on).
trunk_branch
The trunk branch: the remote’s default branch when known locally, otherwise a conventional name that exists.
undo
Restore the most recent snapshot: reset branch tips and metadata to their pre-mutation state. Refuses on a dirty worktree (it resets the current branch) and consumes the snapshot so it is one-shot.
unset_base_for_branch
unset_parent_for_branch