diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-06-21 16:02:29 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-06-21 16:16:05 -0400 |
commit | b6aadd32ffbfd0c592753fc92d2d5e841e9288aa (patch) | |
tree | ced461ef0135addadbb2a0f540c1b6263cf3a6d1 | |
parent | 4723cf025bcf4e18025e1cb0e89c005f322932a7 (diff) |
Fix handling of --no-gitconfig
-rw-r--r-- | src/features/mod.rs | 4 | ||||
-rw-r--r-- | src/get_option_value.rs | 20 | ||||
-rw-r--r-- | src/set_options.rs | 3 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/features/mod.rs b/src/features/mod.rs index 9bcccf0d..71d9879d 100644 --- a/src/features/mod.rs +++ b/src/features/mod.rs @@ -51,8 +51,8 @@ macro_rules! builtin_feature { ( $option_name.to_string(), Box::new(move |$opt: &$crate::cli::Opt, git_config: &Option<$crate::git_config::GitConfig>| { - match (git_config, $git_config_key) { - (Some(git_config), Some(git_config_key)) => match git_config.get::<$type>(git_config_key) { + match (git_config, $git_config_key, $opt.no_gitconfig) { + (Some(git_config), Some(git_config_key), false) => match git_config.get::<$type>(git_config_key) { Some(value) => Some($crate::features::GitConfigValue(value.into())), _ => None, }, diff --git a/src/get_option_value.rs b/src/get_option_value.rs index bce309c1..1eaa93d9 100644 --- a/src/get_option_value.rs +++ b/src/get_option_value.rs @@ -51,9 +51,11 @@ pub trait GetOptionValue { Self: From<OptionValue>, Self: Into<OptionValue>, { - if let Some(git_config) = git_config { - if let Some(value) = git_config.get::<Self>(&format!("delta.{}", option_name)) { - return Some(value); + if !opt.no_gitconfig { + if let Some(git_config) = git_config { + if let Some(value) = git_config.get::<Self>(&format!("delta.{}", option_name)) { + return Some(value); + } } } for feature in opt.features.to_lowercase().split_whitespace().rev() { @@ -88,11 +90,13 @@ pub trait GetOptionValue { Self: GitConfigGet, Self: Into<OptionValue>, { - if let Some(git_config) = git_config { - if let Some(value) = - git_config.get::<Self>(&format!("delta.{}.{}", feature, option_name)) - { - return Some(GitConfigValue(value.into())); + if !opt.no_gitconfig { + if let Some(git_config) = git_config { + if let Some(value) = + git_config.get::<Self>(&format!("delta.{}.{}", feature, option_name)) + { + return Some(GitConfigValue(value.into())); + } } } if let Some(builtin_feature) = builtin_features.get(feature) { diff --git a/src/set_options.rs b/src/set_options.rs index 28d84a7d..3f0fdce8 100644 --- a/src/set_options.rs +++ b/src/set_options.rs @@ -23,9 +23,6 @@ pub fn set_options( git_config: &mut Option<git_config::GitConfig>, arg_matches: &clap::ArgMatches, ) { - if opt.no_gitconfig { - return; - } // Handle options which default to an arbitrary git config value. // TODO: incorporate this logic into the set_options macro. if !config::user_supplied_option("whitespace-error-style", arg_matches) { |