1 //! Bindings to libgit2's git_libgit2_opts function.
2 
3 use crate::raw;
4 
5 /// Controls whether or not libgit2 will verify that objects loaded have the
6 /// expected hash. Enabled by default, but disabling this can significantly
7 /// improve performance, at the cost of relying on repository integrity
8 /// without checking it.
strict_hash_verification(enabled: bool)9 pub fn strict_hash_verification(enabled: bool) {
10     let error = unsafe {
11         raw::git_libgit2_opts(
12             raw::GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION as libc::c_int,
13             if enabled { 1 } else { 0 } as libc::c_int,
14         )
15     };
16     // This function cannot actually fail, but the function has an error return
17     // for other options that can.
18     debug_assert!(error >= 0);
19 }
20 
21 #[cfg(test)]
22 mod test {
23     #[test]
smoke()24     fn smoke() {
25         super::strict_hash_verification(false);
26     }
27 }
28