pub enum GitPatchRecord<'a> {
File {
st: u8,
similarity: u8,
flags: u8,
old_path: &'a str,
new_path: &'a str,
},
Row {
old_line: u32,
new_line: u32,
old_text: &'a [u8],
new_text: &'a [u8],
old_spans: Vec<(u32, u32)>,
new_spans: Vec<(u32, u32)>,
},
Gap {
old_line: u32,
new_line: u32,
},
Base {
oid: GitOid,
},
Cursor {
after: &'a str,
pos: u64,
},
}Expand description
One decoded record from a structured GIT_PATCH response payload.
Variants§
File
PATCH_FILE 0x01: [kind:1][st:1][similarity:1][flags:1]
[old_len:2][old_path:N][new_len:2][new_path:N]
Begins a file section. st/similarity lead, mirroring
DIFF_ENTRY field for field, so a consumer has one status alphabet
and one field order across both views — and so a binary or empty
added file, which emits no rows at all, still says whether it was
added, deleted or modified. old_path carries the old path whenever
there is one, not only for renames.
Row
PATCH_ROW 0x02: [kind:1][old_line:4][new_line:4] [old_text_len:4][old_text:N][new_text_len:4][new_text:N] [n_old_spans:2][spans:(start:4,len:4)·N][n_new_spans:2][spans:(start:4,len:4)·N] Line numbers are 1-based; 0 = side absent (pure addition/deletion). Text is the side’s true bytes; spans are byte ranges within it.
Fields
Gap
PATCH_GAP 0x03: [kind:1][old_line:4][new_line:4] Elision between hunks (the “@@” of a unified diff).
Base
BASE 0x04: [kind:1][oid:32] — as in GIT_DIFF.
Cursor
CURSOR 0x7F: continue with after/pos as the request’s
after/after_pos, so a file past the byte budget resumes
mid-hunk rather than restarting.
Trait Implementations§
Source§impl<'a> Clone for GitPatchRecord<'a>
impl<'a> Clone for GitPatchRecord<'a>
Source§fn clone(&self) -> GitPatchRecord<'a>
fn clone(&self) -> GitPatchRecord<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more