Skip to main content

Module capture_order

Module capture_order 

Source
Expand description

The capture under capture order: the capture lock, the store identity, the sequence and captured.json. What: The capture under capture order: the per-worktree capture lock, the store identity, the sequence allocation and its durable write, the listing of the paths the capture read from the worktree, and captured.json. Why: Every commit transaction captures its content while holding the short per-worktree capture lock and takes the next sequence number under it, so sequence numbers give one total order of the captured disk states of a worktree. The incumbent and this wrapper share the store, so the lock, the identity and the write order must match exactly (src/policy-engine/commit-capture-order-store.ts, commit-capture-order-capture.ts).

In TS you’d write (pseudocode):

const { stamp, value } = await captureInOrder({ gitDir, capture });

Structs§

CaptureIndexes
What: The index and object-store inputs of one listing. Why: Staging and listing read the private index, and only staging writes objects into the shadow store.
CaptureStamp
What: Position of one capture in its worktree’s capture order. Why: Sequence numbers are only comparable within one store generation, so the identity travels with the number.

Enums§

CaptureOrderError
Failure of a capture under capture order. Each variant keeps the incumbent’s wording, so a diagnostic reads the same from either wrapper.

Constants§

CAPTURED_FILENAME
Name of the captured record inside a transaction directory.

Functions§

capture_commit_content
What: Runs the capture under capture order and journals it. Why: The sequence is taken before the capture reads any bytes, and captured.json is written only after the worktree listing is known.
capture_in_order
What: Runs one capture under the per-worktree capture lock and stamps it with the next sequence number. Why: The lock is held only for the capture itself, never across hooks, the editor or landing.
indexed_request
What: A Git request that reads or writes one private index, ignoring the invocation’s global options as the incumbent does. Why: GIT_INDEX_FILE and GIT_OBJECT_DIRECTORY select the private state.
list_worktree_captured_paths
What: Lists the paths the capture read from the worktree, in the incumbent’s order. Why: Explicit-path commits read every path the private index changes against the base; index commits that stage worktree content read only the paths their staging changed; any other index commit read no worktree bytes at capture.
write_captured_record
What: Writes captured.json exclusively and makes it durable. Why: A transaction directory holds one captured record, and a second write means a bug, so the exclusive open refuses it.
write_sequence
What: Writes the sequence file through a temporary file and a rename, so a reader sees the old number or the new one. Why: A crash after the rename leaves only a gap in the numbers.