Expand description
Messages between the wrapper and the resident commit service.
What:
The messages between the wrapper and the resident commit service, one JSON object per line.
Why:
A client sends a prepared change with a request identity and waits; the service answers with a landing, a queue
position, a request to prepare again, or a failure from a closed list. The line form needs no framing library and
every field is checked on read, so a damaged or hostile line is refused rather than guessed
(doc/planning/cli-git-resident-service.md, “Protocol and request identity”).
In TS you’d write (pseudocode):
socket.write(JSON.stringify(encodeRequest(request)) + '\n'); const reply = decodeResponse(await readLine(socket));Structs§
- Change
- What: One path a commit changes: a file to set, or a file to delete. Why: The client has already written the file’s content into the repository’s object store, so the service names the object and never reads the user’s worktree.
- Cleanup
- What:
What the landing of a merge, cherry-pick or revert conclusion removes from the worktree’s Git directory once the
commit is on the branch.
Why:
Native
git commitremovesMERGE_HEADand its siblings when it concludes; the client built the commit with real Git in a scratch repository that holds the state it was given, so the entries real Git removed there are the ones the landing removes here, each only while it still holds the bytes copied at preparation. - Commit
Request - What: A request to land one commit. Why: Every field the service needs to land it on the current branch without asking the client anything.
- Landed
Capture - A commit the service landed and when its bytes were captured, as the service tells a client whose commit it sends back.
Enums§
- Client
Message - What a client sends.
- Failure
Code - The closed list of reasons the service gives for not landing a request.
- Service
Message - What the service sends.
Constants§
- ALLOWED_
MODES - Modes a change may give a file.
- MAX_
CHANGES - The most paths one request may change.
- MAX_
LINE_ BYTES - The longest line either side accepts, in bytes.
- PROTOCOL_
VERSION - The protocol version this build speaks; a service and a client agree when their versions are equal.
- RELEASE
- The release of this build: the crate version, which the wrapper and the service program share because they are built and installed together. A service from another release is retired even when it speaks the same protocol, since the program its unit names, and the behavior behind the same messages, may differ.
- SCRATCH_
PREFIX - The name prefix of a commit’s scratch directory.
Functions§
- decode_
client - What: Reads and checks one client line. Why: The service trusts nothing from a socket: sizes, names, paths, modes and the object names are all checked.
- decode_
service - What: Reads one service line. Why: The client checks what it is told as strictly as the service checks what it is sent.
- encode_
client - What: The line for a client message. Why: One object per line, no newline inside any field.
- encode_
retire - What: The line that asks a service to retire, written in the protocol version that service speaks. Why: A service reads a line only in its own version, except that services built with this check read a retire at any version. A service of an earlier release (the ones that sent no release in their greeting) refuses a retire written in a newer version as unsupported and stays, so the line must carry the version the service announced.
- encode_
service - What: The line for a service message. Why: The same one-object form in the other direction.
- is_
object_ name - Whether
textis a full object name in hexadecimal (40 or 64 digits). - is_
plain_ path - Whether
pathis a plain repository-relative path: no leading slash, no empty,.or..part, no NUL or newline. - is_
scratch_ path - What:
Whether
pathis the scratch directory of a commit in the worktree whose own Git directory isgit_dir. Why: The service removes whatever a client names when the client’s connection closes, so the name must be one only the wrapper makes (the prefix and an identity of letters, digits and dashes) and the place must be directly inside the worktree’s own Git directory, with no relative part that could lead elsewhere. - is_
zero_ object - Whether
nameis the all-zero object name, which stands for a branch that does not exist yet.