From 095fb9fef4b1f25377576c4d9d56a3876106c949 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 19 Mar 2022 10:17:30 -0700 Subject: [PATCH] config: drop support for `~/.jjconfig` I'm a little hesitant to do this because most tools I'm familiar with have the config file directly in `~/`. It's also easier to describe where to put the file if it doesn't vary across platforms. But we're still early in the project, so let's try it and see if we get any complaints. --- CHANGELOG.md | 8 ++++++++ README.md | 6 +++--- docs/tutorial.md | 4 ++-- src/main.rs | 31 +++---------------------------- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bed9d330..7f9a4ef0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Breaking changes + +* Dropped support for config in `~/.jjconfig`. Your configuration is now read + from `/jj/config.toml`, where `` is + `${XDG_CONFIG_HOME}` or `~/.config/` on Linux, + `~/Library/Application Support/` on macOS, and `~\AppData\Roaming\` on + Windows. + ## [0.3.3] - 2022-03-16 No changes, only trying to get the automated build to work. diff --git a/README.md b/README.md index 7c3df7b54..130867732 100644 --- a/README.md +++ b/README.md @@ -197,10 +197,10 @@ cargo install --git https://github.com/martinvonz/jj.git You may want to configure your name and email so commits are made in your name. Create a file at `/jj/config.toml` (where `` is `${XDG_CONFIG_HOME}` or `~/.config/` on Linux, `~/Library/Application Support/` -on macOS, and `~\AppData\Roaming\` on Windows) or `~/.jjconfig` and make it -look something like this: +on macOS, and `~\AppData\Roaming\` on Windows) and make it look something like +this: ```shell script -$ cat ~/.jjconfig +$ cat ~/.config/jj/config.toml [user] name = "Martin von Zweigbergk" email = "martinvonz@google.com" diff --git a/docs/tutorial.md b/docs/tutorial.md index be198a43a..f461bb8a7 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -176,7 +176,7 @@ ancestors (`:foo`), descendants (`foo:`), DAG range (`foo:bar`, like `git log --ancestry-path`), range (`foo..bar`, same as Git's). There are also a few more functions, such as `heads()`, which filters out revisions in the input set if they're ancestors of other revisions in the set. Let's define an -alias based on that by adding the following to `~/.jjconfig`: +alias based on that by adding the following to `~/.config/jj/config.toml`: ``` [alias] l = ["log", "-r", "(heads(remote_branches())..@):"] @@ -349,7 +349,7 @@ try `jj l --at-op=401652a2f61e` but use the hash from your own `jj op log`. You have already seen how `jj squash` can combine the changes from two commits into one. There are several other commands for changing the contents of existing commits. These commands assume that you have `meld` installed. If you prefer -`vimdiff`, add this to your `~/.jjconfig` file: +`vimdiff`, add this to your `~/.config/jj/config.toml` file: ``` [ui] diff-editor = "vimdiff" diff --git a/src/main.rs b/src/main.rs index 122ddf3e2..a073950dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,41 +18,16 @@ use jujutsu::commands::dispatch; use jujutsu::ui::Ui; use jujutsu_lib::settings::UserSettings; -const TOO_MUCH_CONFIG_ERROR: &str = - "Both `$HOME/.jjconfig` and `$XDG_CONFIG_HOME/jj/config.toml` were found, please remove one."; - fn read_config() -> Result { let mut config_builder = config::Config::builder(); - let loaded_from_config_dir = match dirs::config_dir() { - None => false, - Some(config_dir) => { - let p = config_dir.join("jj/config.toml"); - let exists = p.exists(); - config_builder = config_builder.add_source( - config::File::from(p) - .required(false) - .format(config::FileFormat::Toml), - ); - exists - } - }; - - if let Some(home_dir) = dirs::home_dir() { - let p = home_dir.join(".jjconfig"); - // we already loaded from the new location, prevent user confusion and make them - // remove the old one: - if loaded_from_config_dir && p.exists() { - return Err(config::ConfigError::Message( - TOO_MUCH_CONFIG_ERROR.to_string(), - )); - } + if let Some(config_dir) = dirs::config_dir() { config_builder = config_builder.add_source( - config::File::from(p) + config::File::from(config_dir.join("jj/config.toml")) .required(false) .format(config::FileFormat::Toml), ); - } + }; // TODO: Make the config from environment a separate source instead? Seems // cleaner to separate it like that, especially if the config::Config instance