MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse_post_rewrite_pair

Function parse_post_rewrite_pair

atomic-core/src/operation/mod.rs:630–639  ·  view source on GitHub ↗

Parse a post-rewrite event's ` ` full-OID pair (review D3). The RFC §5.4 operation-linkage tier binds a captured post-rewrite event to the operation that performed the rewrite, so the event bytes must name exactly two full-length OIDs separated by whitespace — the Git post-rewrite wire format. `None` means the bytes cannot describe a rewrite pair at all.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

628/// post-rewrite wire format. `None` means the bytes cannot describe a
629/// rewrite pair at all.
630pub fn parse_post_rewrite_pair(bytes: &[u8]) -> Option<(GitObjectId, GitObjectId)> {
631 let text = std::str::from_utf8(bytes).ok()?;
632 let mut tokens = text.split_whitespace();
633 let old = tokens.next()?;
634 let new = tokens.next()?;
635 if tokens.next().is_some() {
636 return None;
637 }
638 Some((parse_git_oid_hex(old)?, parse_git_oid_hex(new)?))
639}
640
641/// Parse a post-rewrite event's rewrite pairs (review D3).
642///

Callers

nothing calls this directly

Calls 3

parse_git_oid_hexFunction · 0.70
okMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected