diff --git a/deny.toml b/deny.toml index bf86226c8..9aaa8da3b 100644 --- a/deny.toml +++ b/deny.toml @@ -97,7 +97,6 @@ allow = [ "MIT", "MPL-2.0", "OpenSSL", - "Unicode-3.0", "Unicode-DFS-2016", ] # The confidence threshold for detecting a license from license text. diff --git a/docs/configuration.md b/docs/configuration.md index a5189032f..7c60eaab0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -313,6 +313,15 @@ of `~/.config/mise/config.toml`. Disables the specified tools. Separate with `,`. Generally used for core plugins but works with any tool. +### `libgit2` + +* Type: `bool` +* Env: `MISE_LIBGIT2` +* Default: `true` + +Use libgit2 for git operations. This is generally faster but may not be as compatible if the +system's libgit2 is not the same version as the one used by mise. + ### `status.missing_tools` * Type: `enum` diff --git a/schema/mise.json b/schema/mise.json index 633621faf..a9d678d07 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -337,6 +337,11 @@ }, "type": "array" }, + "libgit2": { + "description": "use libgit2 for git operations", + "type": "boolean", + "default": true + }, "node_compile": { "description": "do not use precompiled binaries for node", "type": "boolean" diff --git a/src/cli/settings/ls.rs b/src/cli/settings/ls.rs index 2a7dc14c6..188faf50a 100644 --- a/src/cli/settings/ls.rs +++ b/src/cli/settings/ls.rs @@ -79,6 +79,7 @@ mod tests { jobs = 2 legacy_version_file = true legacy_version_file_disable_tools = [] + libgit2 = true node_compile = false not_found_auto_install = true paranoid = false @@ -122,6 +123,7 @@ mod tests { jobs legacy_version_file legacy_version_file_disable_tools + libgit2 node_compile not_found_auto_install paranoid diff --git a/src/cli/settings/set.rs b/src/cli/settings/set.rs index e586247fe..349925af9 100644 --- a/src/cli/settings/set.rs +++ b/src/cli/settings/set.rs @@ -144,6 +144,7 @@ pub mod tests { jobs = 2 legacy_version_file = false legacy_version_file_disable_tools = [] + libgit2 = true node_compile = false not_found_auto_install = true paranoid = false diff --git a/src/cli/settings/unset.rs b/src/cli/settings/unset.rs index e95e7eba3..eaa51c731 100644 --- a/src/cli/settings/unset.rs +++ b/src/cli/settings/unset.rs @@ -70,6 +70,7 @@ mod tests { jobs = 4 legacy_version_file = true legacy_version_file_disable_tools = [] + libgit2 = true node_compile = false not_found_auto_install = true paranoid = false diff --git a/src/config/settings.rs b/src/config/settings.rs index 46f8fc437..24b3c2cdd 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -82,6 +82,8 @@ pub struct Settings { pub legacy_version_file: bool, #[config(env = "MISE_LEGACY_VERSION_FILE_DISABLE_TOOLS", default = [], parse_env = list_by_comma)] pub legacy_version_file_disable_tools: BTreeSet, + #[config(env = "MISE_LIBGIT2", default = true)] + pub libgit2: bool, #[config(env = "MISE_NODE_COMPILE", default = false)] pub node_compile: bool, #[config(env = "MISE_NOT_FOUND_AUTO_INSTALL", default = true)] diff --git a/src/git.rs b/src/git.rs index 0e2792ef0..a53d68dcf 100644 --- a/src/git.rs +++ b/src/git.rs @@ -7,6 +7,7 @@ use once_cell::sync::OnceCell; use xx::file; use crate::cmd; +use crate::config::Settings; use crate::file::touch_dir; pub struct Git { @@ -44,7 +45,11 @@ impl Git { pub fn repo(&self) -> Result<&git2::Repository> { self.repo.get_or_try_init(|| { - trace!("opening git repository at {:?}", self.dir); + if !Settings::get().libgit2 { + trace!("libgit2 is disabled"); + return Err(eyre!("libgit2 is disabled")); + } + trace!("opening git repository via libgit2 at {:?}", self.dir); git2::Repository::open(&self.dir) .wrap_err_with(|| format!("failed to open git repository at {:?}", self.dir)) .inspect_err(|err| warn!("{err:#}"))