Skip to content

Commit

Permalink
config: add function to resolve conditional tables
Browse files Browse the repository at this point in the history
This provides an inline version of Git's includeIf. The idea is that each config
layer has an optional key "--when" to enable the layer, and a layer may have
multiple sub-layer tables "--scope" to inline stuff. Layers can be nested, but
that wouldn't be useful in practice.

I choose "--" prefix to make these meta keys look special (and are placed
earlier in lexicographical order), but I don't have strong opinion about that.
We can use whatever names that are unlikely to conflict with the other config
sections.

resolve() isn't exported as a StackedConfig method because it doesn't make
sense to call resolve() on "resolved" StackedConfig. I'll add a newtype in
CLI layer to distinguish raw config from resolved one. Most consumers will
just see the "resolved" config.

jj-vcs#616
  • Loading branch information
yuja committed Dec 18, 2024
1 parent fd79151 commit 20414da
Show file tree
Hide file tree
Showing 3 changed files with 448 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ use thiserror::Error;
use toml_edit::DocumentMut;
use toml_edit::ImDocument;

pub use crate::config_resolver::resolve;
pub use crate::config_resolver::ConfigResolutionContext;
use crate::file_util::IoResultExt as _;
use crate::file_util::PathError;

Expand Down
Loading

0 comments on commit 20414da

Please sign in to comment.