Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: ability to disable default configs #5538

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* Conditional configuration now supports `--when.commands` to change configuration
based on subcommand.

* New `JJ_NO_DEFAULT_COLORS` environment variable disables setting build-in default colors.

### Fixed bugs

* `jj git fetch` with multiple remotes will now fetch from all remotes before
Expand Down
24 changes: 17 additions & 7 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,23 @@ 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 = {
let maybe_colors = if env::var("JJ_NO_DEFAULT_COLORS").is_ok() {
vec![]
} else {
vec![parse(include_str!("config/colors.toml"))]
};
[
maybe_colors,
vec![
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")),
],
]
.concat()
};
if cfg!(unix) {
layers.push(parse(include_str!("config/unix.toml")));
}
Expand Down
Loading