Skip to content

Commit 405b76b

Browse files
authored
Always initialize when setting global opts (#894)
1 parent 3954d34 commit 405b76b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/opts.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub unsafe fn get_search_path(level: ConfigLevel) -> Result<CString, Error> {
7777
/// Disabling this will cause repository objects to clear their caches when next
7878
/// accessed.
7979
pub fn enable_caching(enabled: bool) {
80+
crate::init();
8081
let error = unsafe {
8182
raw::git_libgit2_opts(
8283
raw::GIT_OPT_ENABLE_CACHING as libc::c_int,
@@ -94,6 +95,7 @@ pub fn enable_caching(enabled: bool) {
9495
/// creation of objects that reference invalid objects (due to programming
9596
/// error or repository corruption).
9697
pub fn strict_object_creation(enabled: bool) {
98+
crate::init();
9799
let error = unsafe {
98100
raw::git_libgit2_opts(
99101
raw::GIT_OPT_ENABLE_STRICT_OBJECT_CREATION as libc::c_int,
@@ -110,6 +112,7 @@ pub fn strict_object_creation(enabled: bool) {
110112
/// improve performance, at the cost of relying on repository integrity
111113
/// without checking it.
112114
pub fn strict_hash_verification(enabled: bool) {
115+
crate::init();
113116
let error = unsafe {
114117
raw::git_libgit2_opts(
115118
raw::GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION as libc::c_int,
@@ -181,6 +184,7 @@ where
181184
/// Set wheter or not to verify ownership before performing a repository.
182185
/// Enabled by default, but disabling this can lead to code execution vulnerabilities.
183186
pub unsafe fn set_verify_owner_validation(enabled: bool) -> Result<(), Error> {
187+
crate::init();
184188
let error = raw::git_libgit2_opts(
185189
raw::GIT_OPT_SET_OWNER_VALIDATION as libc::c_int,
186190
enabled as libc::c_int,

0 commit comments

Comments
 (0)