Expand description
Single-flight push coordination per branch: owner lock, record joins and the push itself.
What:
Single-flight auto-push per branch: one owner lock serializes the pushes of a branch,
and the last-pushed record names the most recent attempt.
Why:
A commit that a recorded successful push already covers finishes without pushing,
and a commit that waits behind a live pusher joins the push it waited for,
so concurrent landings on one branch cost fewer pushes than commits.
The incumbent’s src/auto-push-single-flight.ts decides these joins,
and the lock and record paths must match its paths byte for byte.
In TS you’d write (pseudocode):
await runSingleFlightPush({ gitPath, cwd, branchRef, landedOid, push, onWait });Structs§
- Push
Attempt - What:
One push this invocation ran itself.
Why:
outputis Git’s interleaved output with one trailing line break removed, as the incumbent’snano-spawnoutputis; a successful push’s output is never recorded. - Push
Coordination Paths - What: Paths of one branch’s coordination files. Why: The lock and the record live beside each other under the common Git directory.
- PushGit
- What:
The real Git a coordinator runs, where, and with which environment.
Why:
The incumbent’s coordination inherits the wrapper’s whole environment plus the child-environment overlay,
so the caller passes that complete environment in (
environment_with_overlay) and nothing is read from the process environment here. - Single
Flight Outcome - What: How a landed commit’s auto-push finished, with the deciding push’s facts. Why: The caller prints the output and the uncovered note from these fields alone.
Enums§
- Single
Flight Error - What: Why a single-flight push could not finish. Why: Every variant is a coordination failure, which the caller reports and keeps the commit for.
- Single
Flight Kind - What: How a landed commit’s auto-push finished. Why: The four kinds keep “this invocation pushed” apart from “another invocation’s push decided”, because only the owner of a failed push prints its full output.
Functions§
- git_
command - What: Build a real Git command with the given arguments, directory and environment. Why: Every coordination query and push starts Git this way, so none re-enters the wrapper.
- git_
output - What:
Run a read-only Git query and return its trimmed standard output.
Result<A, B>is either the output or a failure. Why: Any failed query is a coordination failure; it is never read as an answer. - resolve_
push_ coordination_ paths - What: Resolve one branch’s coordination file paths under the common Git directory and create that directory. Why: Linked worktrees share one common directory, so every worktree of a repository coordinates on one lock.
- run_
query - What: Run a read-only Git query with its own deadline and capture its streams separately. Why: A query that never returns would hold the caller, and the push lock behind it, for good.
- run_
single_ flight_ push - What: Finish auto-push of one landed commit: join a push that covers it, or push the branch tip itself. Why: Three joins are possible, and each keeps the commit from pushing twice: an early join on a recorded covering success, a join after waiting for the lock, and the rule that a failed record joins only when a push finished after the first read. The record is written before the lock is released, so the next waiter reads this attempt.
- tip_
contains - What:
Whether a commit is the given tip or one of its ancestors.
Result<A, B>is “answer or failure”. Why: Only Git’s “not an ancestor” status answers no; every other failure stops the caller.