Skip to content

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 15 Oct 15:42
· 40 commits to main since this release

This release adds absorb, reorder, move and init, so fixing a commit lower down or changing the shape of a stack no longer means dropping back to gh stack, plus submit --down for sending just the bottom of a stack for review.

New

git stack absorb

Fixing a review comment on the third PR down used to mean git down twice, git modify -p, git top, and getting the hunk selection right by hand. Now you stage the fixes and run git absorb (or git ab), and each run of changed lines goes into the commit in the stack that last changed those lines. That commit and everything above it gets rewritten (messages and authors kept), then the branches above are restacked. It doesn't push.

❯ git absorb
  pkg/app/sync.go:120-125  into 7ac32ef Give up on a webhook after five attempts (billing-webhook-retries)
  pkg/app/sync.go:300  into 4f21abc Version the billing webhook payload (billing-webhook-schema)
  README.md:12  not absorbed; no commit in this stack changed those lines
? Absorb 2 hunks into 2 commits? [Y/n]

On a terminal you see the plan and get asked first; --dry-run just shows it and --force skips the question. It goes by lines, not meaning, so lines no commit in the stack touched (and new or deleted files) stay staged, and a run of changes spanning two commits' lines goes to the newer one rather than being split. The old tips are printed, and the README has the recipe for putting things back if it picked the wrong commit. Agents get it as stack_absorb.

git stack reorder

Changes the order of the branches in the stack you're on. On a terminal it shows the stack as a small list (j/k to move the cursor, J/K or shift with the arrows to move a branch, enter to apply); otherwise pass the new order as arguments, bottom to top. A conflict stops just like a restack, and git abort puts the old order back along with the branches.

GitHub can't reorder a stack in place, so if it already has PRs the next git ss dissolves it on GitHub and creates it again in the new order. The PRs stay the same, but the stack's number changes.

git stack move

Takes the current branch, and everything above it, out of its stack and puts it on top of another stack or onto a trunk as a new stack (which can be a different trunk, e.g. moving a stack from main to develop). --only moves just that branch and leaves the ones above behind. Without --onto you get the checkout picker, showing only the places it can actually go.

❯ git move --onto main --only
✔ Moved billing-webhook-alerts from billing-webhook-schema onto main (new stack)
  billing-webhook-retries stays on billing-webhook-schema

Same as reorder, the next git ss sorts out the stacks on GitHub, and its notices say what it did with each one.

git stack init (alias track)

Tracks branches you already have (e.g. ones you made with plain git) as a new stack. It only records the stack; nothing is committed, rebased or checked out, so if a branch isn't sitting on the one below it you're told to run git restack. The alias is git track since git won't let an alias replace its own git init.

❯ git track search-index search-api search-ui
✔ Tracking search-index, search-api, search-ui on main

Reorder, move and init are stack_reorder, stack_move and stack_init for agents, so they can reshape a stack without shelling out.

git stack submit --down

Thanks to @StillAyo for this one. git stack submit --down submits the current branch and everything below it, and git stack submit <branch> does the same up to the named branch, leaving the branches above alone. Handy for getting the bottom of a stack reviewed while you keep working on the top.

gh stack can only submit a whole stack, so here git-stack pushes those branches itself (still with --force-with-lease, so it won't overwrite commits someone else pushed), creates any missing PRs and links them into the stack on GitHub. gh stack's editor isn't available on that path, so new PRs take their titles from their commits unless you pass --ai. Plain git ss is unchanged. Agents get it through down and branch on stack_submit.

After upgrading

The new aliases (git absorb, git ab, git reorder, git move and git track) are installed by git stack install, so run it once to pick them up.

What's Changed

New features

  • Add git stack absorb and stack_absorb by @DomBlack in #37
  • Add submit --down to submit only up to a branch by @StillAyo in #39
  • Add git stack reorder, move and init by @DomBlack in #42

Under the hood

  • Parse diffs and plan where each staged hunk belongs by @DomBlack in #35
  • Rewrite a stack's commits from an absorb plan by @DomBlack in #36
  • Teach the metadata adapter and restack engine about reshapes by @DomBlack in #40
  • Add reorder, move and init use cases by @DomBlack in #41

New Contributors

Full Changelog: v0.2.3...v0.3.0

Upgrading

git stack update swaps the binary in place, after checking the archive against
checksums.txt. New to git-stack? Start with the install guide.