Expand description
An explicit push that lost a race: run as a child, merge in what landed on the remote and publish the merge.
What:
An explicit git push that lost a race: the commits that landed on the remote since the local base are merged in
the object store, and the merge is published by the wrapper pushing it again through its own gates.
Why:
Several sessions push to one branch all day; a push rejected because the remote moved cannot succeed again,
and every caller would fetch, merge or rebase and retry by hand while racing the others.
The wrapper runs an eligible push as a child with the caller’s streams, so Git’s own output is unchanged.
Only a failed push is looked at again, and only a divergence of the destination is acted on;
an authentication, offline, hook or rule refusal keeps the exit status and the text Git gave.
The merge is pushed by this executable with STACKED_PUSH_MARKER set, so the policies that gate any push read the
integrated result, and the marker stops that push from stacking again.
In TS you’d write (pseudocode):
const code = await runPush(args); if (code !== 0) code = (await stackFailedPush({ args })) ?? code;Structs§
- Stack
Request - What a failed explicit push needs to be integrated.
Constants§
- STACKED_
PUSH_ MARKER - The environment variable the stacked push carries so that it is never stacked again.
Functions§
- run_
stacked_ push - What: Run an eligible explicit push as a child with the caller’s streams, then integrate it when it failed on a divergence. Why: The wrapper must outlive Git to look at its status; nothing is buffered, so Git’s own output is what the person sees.
- stack_
failed_ push - What:
Integrate the remote’s new commits after an explicit push failed, or say nothing when the failure was no divergence.
Option<i32>is “the new exit status, or nothing to change”. Why: The status is0when the merge was published, and the failing status when the run says why it was not (a conflict, a gate that refused the merge, a remote that kept moving); every other failure returns nothing and prints nothing, so the person sees only Git’s own report.