MCPcopy Create free account
hub / github.com/git/git / new

Method new

src/hash.rs:48–56  ·  view source on GitHub ↗

Return a new object ID with the given algorithm and hash. `hash` must be exactly the proper length for `algo` and this function panics if it is not. The extra internal storage of `hash`, if any, is zero filled.

(algo: HashAlgorithm, hash: &[u8])

Source from the content-addressed store, hash-verified

46 /// `hash` must be exactly the proper length for `algo` and this function panics if it is not.
47 /// The extra internal storage of `hash`, if any, is zero filled.
48 pub fn new(algo: HashAlgorithm, hash: &[u8]) -> Self {
49 let mut data = [0u8; GIT_MAX_RAWSZ];
50 // This verifies that the length of `hash` is correct.
51 data[0..algo.raw_len()].copy_from_slice(hash);
52 Self {
53 hash: data,
54 algo: algo as u32,
55 }
56 }
57
58 /// Return the algorithm for this object ID.
59 ///

Callers

nothing calls this directly

Calls 4

git_hash_allocFunction · 0.85
git_hash_initFunction · 0.85
raw_lenMethod · 0.80
hash_algo_ptrMethod · 0.80

Tested by

no test coverage detected