Skip to content

Commit

Permalink
cli: ability to disable default colors
Browse files Browse the repository at this point in the history
My motivation is mostly to address #5098, even as a stopgap meassure.
  • Loading branch information
dpc committed Feb 4, 2025
1 parent 0bcddff commit b7bec6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
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

0 comments on commit b7bec6b

Please sign in to comment.