Expand description
Pure parsing of raw NUL-delimited changed-path records.
What:
Parse the NUL-delimited raw records of git diff-index and git diff-tree.
Why:
One listing process names every changed path with its mode,
object and change
kind,
so no per-path Git process is ever needed.
Pathnames are kept as the raw
bytes Git printed;
they are never decoded.
Git 2.56.0 (Documentation/diff-format.adoc,
“RAW OUTPUT FORMAT”) prints,
with -z:
:<old mode> SP <new mode> SP <old oid> SP <new oid> SP <status> NUL <path> NUL.
In TS you’d write (pseudocode):
// const records = parseRawRecords(stdout); // [{ path, mode, change, object }]Structs§
- Candidate
Record - What:
One listed path.
Vec<u8>is an owned byte list (siblingStringwould require UTF-8).Option<ObjectId>is “an object name or nothing”. Why: Git pathnames are arbitrary bytes on Unix and must round-trip exactly. A deleted path has no object on the candidate side, which the type states instead of carrying Git’s all-zero placeholder name.
Enums§
- Candidate
Change - What:
How a path differs from the baseline it was compared with.
#[derive(...)]generates copying, debug printing and==. Why: A deleted path has no content to read, and policies may treat new files differently from changed ones.
Functions§
- parse_
raw_ records - What:
Parse complete raw
-zoutput into records, in Git’s order.&[u8]borrows the output; the records own copies of what they keep. Why: Each record is two NUL-terminated tokens. Output that does not end with a NUL, or that holds an odd number of tokens, was cut short or is not raw output, and is refused whole: a partial list would leave paths unchecked.