Skip to main content

Module auto_push_branch_key

Module auto_push_branch_key 

Source
Expand description

The per-branch push coordination file name: a reversible, flat, case-safe key. What: The reversible, flat, case-insensitive-safe file name of one branch’s push coordination files. Why: The per-branch push lock and last-pushed record live under <git-common-dir>/cli-git/push/, and the incumbent (src/auto-push-branch-key.ts) and this wrapper must name them identically, because both wrappers contend on the same lock while both are installed. Uppercase letters are escaped too, so refs that differ only in case never share a file on a case-insensitive filesystem.

In TS you’d write (pseudocode):

encodeBranchKey('refs/heads/Main'); // 'refs%2Fheads%2F%4Dain'

Structs§

BranchKeyError
What: A push coordination key that encode_branch_key never produces. Why: Decoding a key that the incumbent did not write must stop the caller, never guess a ref name.

Functions§

decode_branch_key
What: Reverse encode_branch_key in one left-to-right pass. Result<A, B> is either the decoded ref name or a BranchKeyError. Why: A key with an unescaped non-verbatim character, a malformed escape, or bytes that are not UTF-8 names no branch and must stop the caller.
encode_branch_key
What: Encode a full ref name as one flat file name component. &str is borrowed UTF-8 text. Why: Each UTF-8 byte outside the verbatim set becomes %XX with uppercase hexadecimal digits, so every ref maps to one reversible name.