History

feat: automatically enforce strict mode if `-c` options are given on the command-line.

This should stop most mistakes right away, instead of possibly silently ignoring them depending on what was hard-coded in the respective sub-command.

Sebastian Thiel committed 3 years ago

Commit f9ae1bc1 parent b2300781 file · +8 −1Browse files

Unified · Split

src/plumbing/main.rs+8−1
@@ -83,8 +83,15 @@ pub fn main() -> Result<()> { · 82 unmodified lines
8383
8484 let repository = {
8585 let config = config.clone();
86− move |mode: Mode| -> Result<gix::Repository> {
86+ move |mut mode: Mode| -> Result<gix::Repository> {
8787 let mut mapping: gix::sec::trust::Mapping<gix::open::Options> = Default::default();
88+ if !config.is_empty() {
89+ mode = match mode {
90+ Mode::Lenient => Mode::Strict,
91+ Mode::LenientWithGitInstallConfig => Mode::StrictWithGitInstallConfig,
92+ _ => mode,
93+ };
94+ }
8895 let strict_toggle = matches!(mode, Mode::Strict | Mode::StrictWithGitInstallConfig) || args.strict;
8996 mapping.full = mapping.full.strict_config(strict_toggle);
9097 mapping.reduced = mapping.reduced.strict_config(strict_toggle);