Scope
One flag says how much of the structure a command means, and it means the same thing whichever record describes the branch.
--scope |
selects |
|---|---|
branch |
just this branch |
path |
the trunk down to this branch |
subtree |
this branch and everything above it |
stack |
this whole stack, trunk to tips |
trunk |
every stack on this trunk |
all |
every stack in the repository (status and prune only) |
Selected from a trunk, stack is the whole tree under it.
A lattice, not a list
Section titled “A lattice, not a list”The values are two halves, toward the trunk and toward the tips, taken separately, together, or neither:
all every trunk's stacks (read-only commands) │ trunk my trunk and everything under it, cousins included │ stack trunk → me → my descendants ╱ ╲ path subtree (trunk → me) (me → my descendants) ╲ ╱ branch just meEach value answers something a person says:
| value | the sentence |
|---|---|
branch |
“just rebase me onto my parent, I’ll deal with the rest later” |
path |
“what does GitHub need to see below me” |
subtree |
“my parent’s conflict can wait; get everything above me sitting cleanly” |
stack |
“show me where I am” |
trunk |
“the trunk moved, bring everything on it up to date” |
all |
“show me every stack in this repository” |
stack is what a person means by “my stack”: the path down to the trunk and
everything above, leaving out the cousins that merely share a trunk.
Defaults differ because the commands differ
Section titled “Defaults differ because the commands differ”statusandgithub statusdefault tostack. Reading is free, so show where you are, ancestors and descendants both.restackdefaults tosubtree, because rewriting is not free. A conflict below you may be one you are deliberately deferring, and replaying it uninvited is how restacking from the middle walks into it every time.landdefaults topath, because standing in the middle of a stack and typinglandmeans “as far as here”.prunedefaults tostackand offersall, since it edits only the record and forgets only what has landed.pulloffers onlystackandtrunk. It advances the base and replays what sits on it, so anything narrower would leave the branches below on the old base.untrackoffers onlybranch(its default) andsubtree.
g2g status # where am I: the trunk, me, and everything aboveg2g status --scope path # just the trunk down to meg2g restack --apply # me and what depends on meg2g status --scope all # every stack in the repositoryA command refuses any scope it does not offer. all is offered only where
nothing is rewritten: the read-only commands, and prune. It spans trunks, and
a rewrite acts on one. restack does offer trunk, and a rewrite that wide is
the likeliest to reach a branch checked out in another worktree, which it then
refuses by name.
restack’s default is wider than it once was, and that is not a surprise,
because restack previews by default: widening the default widens what you
read before agreeing to it.
Publishing is linear
Section titled “Publishing is linear”A GitHub native stack is linear, so push, submit, land, github link,
github unlink and github retarget take stack or path only, and refuse a
selection that forks, naming the remedy rather than choosing a line.
Selecting a leaf is that remedy, and it needs no flag. A leaf has no
descendants, so stack collapses to an ordered path by itself.
This is a capability of publishing, not a property of scope. Selecting a subtree to look at does not imply a subtree can be published as a GitHub native stack.
github comment has no --scope. It always keeps the whole stack the branch
belongs to, because each comment draws the stack from its own pull request, and
keeping only part of it would leave the rest describing a different one. See
GitHub.
--no-stack is gone
Section titled “--no-stack is gone”The older --no-stack flag is now --scope branch. Keeping both would have
meant two flags that overlapped, and the overlap was where their meanings
drifted apart.
Further reading
Section titled “Further reading”design-docs/stack-scope.md records why the axis looks the way it does.