Skip to content

Commit

Permalink
cli: ability to disable default configs
Browse files Browse the repository at this point in the history
My motivation is mostly to address #5098 , but in a lot of
software there's a flag to disable sourcing default configs,
which is useful in a lot contexts.

A more granular (or just atlernative/better) approaches
would require more design and debate, while this seems
simple and immediately useful (at least to some).
  • Loading branch information
dpc committed Jan 31, 2025
1 parent 4ac970f commit bbdb7f4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,17 @@ pub fn default_config_layers() -> Vec<ConfigLayer> {
// Syntax error in default config isn't a user error. That's why defaults are
// loaded by separate builder.
let parse = |text: &'static str| ConfigLayer::parse(ConfigSource::Default, text).unwrap();
let mut layers = vec![
parse(include_str!("config/colors.toml")),
parse(include_str!("config/merge_tools.toml")),
parse(include_str!("config/misc.toml")),
parse(include_str!("config/revsets.toml")),
parse(include_str!("config/templates.toml")),
];
let mut layers = if let Some(_) = env::var("JJ_NO_DEFAULT_CONFIG") {
vec![]
} else {
vec![
parse(include_str!("config/colors.toml")),
parse(include_str!("config/merge_tools.toml")),
parse(include_str!("config/misc.toml")),
parse(include_str!("config/revsets.toml")),
parse(include_str!("config/templates.toml")),
]
};
if cfg!(unix) {
layers.push(parse(include_str!("config/unix.toml")));
}
Expand Down

0 comments on commit bbdb7f4

Please sign in to comment.