diff --git a/cli/src/commands/fix.rs b/cli/src/commands/fix.rs index 903d84b1c..91c245170 100644 --- a/cli/src/commands/fix.rs +++ b/cli/src/commands/fix.rs @@ -25,6 +25,7 @@ use jj_lib::backend::BackendError; use jj_lib::backend::CommitId; use jj_lib::backend::FileId; use jj_lib::backend::TreeValue; +use jj_lib::config::ConfigValue; use jj_lib::fileset; use jj_lib::fileset::FilesetDiagnostics; use jj_lib::fileset::FilesetExpression; @@ -470,7 +471,7 @@ fn get_tools_config(ui: &mut Ui, settings: &UserSettings) -> Result("fix.tool-command").unwrap()).unwrap() + to_toml_value(&settings.get::("fix.tool-command").unwrap()).unwrap() )?; } if let Ok(tools_table) = settings.raw_config().get_table("fix.tools") { diff --git a/cli/src/config.rs b/cli/src/config.rs index f9be90e6a..ed112596a 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -26,6 +26,7 @@ use jj_lib::config::ConfigError; use jj_lib::config::ConfigLayer; use jj_lib::config::ConfigNamePathBuf; use jj_lib::config::ConfigSource; +use jj_lib::config::ConfigValue; use jj_lib::config::StackedConfig; use jj_lib::settings::ConfigResultExt as _; use regex::Captures; @@ -51,7 +52,7 @@ pub fn parse_toml_value_or_bare_string(value_str: &str) -> toml_edit::Value { } } -pub fn to_toml_value(value: &config::Value) -> Result { +pub fn to_toml_value(value: &ConfigValue) -> Result { fn type_error(message: T) -> ConfigError { ConfigError::Message(message.to_string()) } @@ -93,7 +94,7 @@ pub struct AnnotatedValue { /// Dotted name path to the configuration variable. pub name: ConfigNamePathBuf, /// Configuration value. - pub value: config::Value, + pub value: ConfigValue, /// Source of the configuration value. pub source: ConfigSource, // TODO: add source file path diff --git a/lib/src/config.rs b/lib/src/config.rs index 923852bd7..ba9f6c43d 100644 --- a/lib/src/config.rs +++ b/lib/src/config.rs @@ -27,6 +27,11 @@ use itertools::Itertools as _; use crate::file_util::IoResultExt as _; +/// Table of config key and value pairs. +pub type ConfigTable = config::Map; +/// Generic config value. +pub type ConfigValue = config::Value; + /// Error that can occur when accessing configuration. // TODO: will be replaced with our custom error type pub type ConfigError = config::ConfigError; @@ -63,11 +68,11 @@ impl ConfigNamePathBuf { /// This is a workaround for the `config.get()` API, which doesn't support /// literal path expression. If we implement our own config abstraction, /// this method should be moved there. - pub fn lookup_value(&self, config: &config::Config) -> Result { + pub fn lookup_value(&self, config: &config::Config) -> Result { // Use config.get() if the TOML keys can be converted to config path // syntax. This should be cheaper than cloning the whole config map. let (key_prefix, components) = self.split_safe_prefix(); - let value: config::Value = match &key_prefix { + let value: ConfigValue = match &key_prefix { Some(key) => config.get(key)?, None => config.collect()?.into(), };