rev_to_oid in cargo::sources::git::utils - Rust
Description: Turns a full commit hash revision into an oid.

Skip to main content

## rev_to_oid

# Function rev_to_oid

Source

    pub(super) fn rev_to_oid(rev: &str) -> Option<Oid>

Expand description

Turns a full commit hash revision into an oid.

Git object ID is supposed to be a hex string of 20 (SHA1) or 32 (SHA256) bytes. Its length must be double to the underlying bytes (40 or 64), otherwise libgit2 would happily zero-pad the returned oid.

See:

- https://github.com/rust-lang/cargo/issues/13188
- https://github.com/rust-lang/cargo/issues/13968