pub enum GitStateRecord<'a> {
Head {
flags: u8,
oid: GitOid,
name: &'a str,
},
Ref {
flags: u8,
oid: GitOid,
peeled: GitOid,
name: &'a str,
target: &'a str,
},
Op {
op: u8,
oid: GitOid,
detail: &'a str,
},
Status {
staged: u8,
unstaged: u8,
flags: u8,
oid: GitOid,
old_path: &'a str,
path: &'a str,
},
Upstream {
flags: u8,
ahead: u32,
behind: u32,
name: &'a str,
upstream: &'a str,
},
Stash {
index: u16,
oid: GitOid,
time: i64,
tz: i16,
msg: &'a str,
},
Remote {
flags: u8,
name: &'a str,
fetch_url: &'a str,
push_url: &'a str,
},
}Expand description
One decoded record from a GIT_STATE payload.
Variants§
Head
HEAD 0x01: [kind:1][flags:1][oid:32][name_len:2][name:N]
name is the symbolic target (empty when detached).
Ref
STATE_REF 0x02: [kind:1][flags:1][oid:32][peeled:32][name_len:2][name:N][target_len:2][target:N]
target is the symbolic target’s full ref name when SYMBOLIC,
else empty — so refs/remotes/origin/HEAD names the default branch
instead of only peeling to its oid.
Op
OP 0x03: [kind:1][op:1][oid:32][detail_len:2][detail:N]
oid is the operation head; an absent record means no operation.
Status
STATUS 0x04: [kind:1][staged:1][unstaged:1][flags:1][oid:32][old_len:2][old_path:N][path_len:2][path:N]
staged/unstaged are porcelain letters (ASCII AMDRTU, ?, !);
old_path is non-empty only for renames.
oid is the worktree content’s hash when the status walk read
the file, else zero. Without it a write that leaves a file’s
letters unchanged — an agent editing the same file over and over —
produces a byte-identical snapshot, which the engine suppresses, so
the server knows the worktree moved and has no way to say so. With
it the existing dedupe does the right thing and no new concept is
needed.
Upstream
UPSTREAM 0x05: [kind:1][flags:1][ahead:4][behind:4][name_len:2][name:N][upstream_len:2][upstream:N]
One per local branch with a configured upstream; name joins
Ref records by ref name.
Stash
STASH 0x06: [kind:1][index:2][oid:32][time:8 i64 s][tz:2 i16 min][msg_len:2][msg:N]
index is the N of stash@{N}, oid the stash commit.
Remote
STATE_REMOTE 0x07: [kind:1][flags:1][name_len:2][name:N][fetch_len:2][fetch_url:N][push_len:2][push_url:N]
One per configured remote, with the REMOTES open flag. URLs go
out as configured, userinfo included: the caller already has a
shell and can read .git/config, so withholding it would only
stop them reproducing the remote. push_url is empty when it
equals fetch_url. Not a general config surface: three named
fields, no key/value access, no writes.
Trait Implementations§
Source§impl<'a> Clone for GitStateRecord<'a>
impl<'a> Clone for GitStateRecord<'a>
Source§fn clone(&self) -> GitStateRecord<'a>
fn clone(&self) -> GitStateRecord<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more