1"""The stack a branch was started on, recorded in the checkout's git config.
3``fm start --from`` records a branch's parent and the parent's tip at
4the start as ``branch.<name>.workshop-parent`` and
5``branch.<name>.workshop-parent-tip``; a sync, a submit and the
6issue verbs read them back here. A branch standing on main has
7neither key.
8"""
18 """The parent *branch* was started on, and the commit it started from.
20 Both are empty for a branch started on main; the commit is empty
21 for a branch started before it was recorded. One process for both
22 keys: a flow reads the stack several times.
23 """
24 prefix = f"branch.{branch}.workshop-parent"
25 found = git.config_regexp(root, f"^{prefix}(-tip)?$")
26 parent = found.get(prefix, "")
27 return parent, found.get(f"{prefix}-tip", "") if parent else ""
31 """Record *branch* as stacked on *parent*, its own commits after *tip*."""
32 git.config_set(root, f"branch.{branch}.workshop-parent", parent)
33 git.config_set(root, f"branch.{branch}.workshop-parent-tip", tip)
37 """Drop the stack record: *branch* stands on main now."""
38 for key in ("workshop-parent", "workshop-parent-tip"):
39 git.config_unset(root, f"branch.{branch}.{key}")