diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d93e165f5b..aca9e466348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * The `jj sparse` subcommands now parse and print patterns as workspace-relative paths. +* The `jj log` command no longer uses the default revset when a path is specified. + ### New features * Config now supports rgb hex colors (in the form `#rrggbb`) wherever existing color names are supported. diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 71af456307e..4564a877134 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -880,7 +880,7 @@ impl WorkspaceCommandHelper { self.attach_revset_evaluator(expression) } - fn attach_revset_evaluator( + pub fn attach_revset_evaluator( &self, expression: Rc, ) -> Result, CommandError> { diff --git a/cli/src/commands/log.rs b/cli/src/commands/log.rs index 93ca0f43e45..0df4ba1bfb1 100644 --- a/cli/src/commands/log.rs +++ b/cli/src/commands/log.rs @@ -38,8 +38,9 @@ use crate::ui::Ui; /// rendered as a synthetic node labeled "(elided revisions)". #[derive(clap::Args, Clone, Debug)] pub(crate) struct LogArgs { - /// Which revisions to show. Defaults to the `revsets.log` setting, or - /// `@ | ancestors(immutable_heads().., 2) | trunk()` if it is not set. + /// Which revisions to show. If no paths nor revisions are specified, this + /// defaults to the `revsets.log` setting, or `@ | + /// ancestors(immutable_heads().., 2) | trunk()` if it is not set. #[arg(long, short)] revisions: Vec, /// Show revisions modifying the given paths @@ -77,10 +78,14 @@ pub(crate) fn cmd_log( let workspace_command = command.workspace_helper(ui)?; let revset_expression = { - let mut expression = if args.revisions.is_empty() { + // only use default revset if neither revset nor path are specified + let mut expression = if args.revisions.is_empty() && args.paths.is_empty() { workspace_command.parse_revset(&command.settings().default_revset())? - } else { + } else if !args.revisions.is_empty() { workspace_command.parse_union_revsets(&args.revisions)? + } else { + // a path was specified so we use all() and add path filter later + workspace_command.attach_revset_evaluator(RevsetExpression::all())? }; if !args.paths.is_empty() { let repo_paths: Vec<_> = args @@ -94,6 +99,7 @@ pub(crate) fn cmd_log( } expression }; + let repo = workspace_command.repo(); let matcher = workspace_command.matcher_from_values(&args.paths)?; let revset = revset_expression.evaluate()?; diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index 8ff377a2f00..0e881954a26 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1025,7 +1025,7 @@ Spans of revisions that are not included in the graph per `--revisions` are rend ###### **Options:** -* `-r`, `--revisions ` — Which revisions to show. Defaults to the `revsets.log` setting, or `@ | ancestors(immutable_heads().., 2) | trunk()` if it is not set +* `-r`, `--revisions ` — Which revisions to show. If no paths nor revisions are specified, this defaults to the `revsets.log` setting, or `@ | ancestors(immutable_heads().., 2) | trunk()` if it is not set * `--reversed` — Show revisions in the opposite order (older revisions first) Possible values: `true`, `false` diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 0782d6ba3a3..0d52f0ddf9c 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -1001,6 +1001,15 @@ fn test_default_revset() { .lines() .count() ); + + // The default revset is not used if a path is specified + insta::assert_snapshot!( + test_env.jj_cmd_success(&repo_path, &["log", "file1", "-T", "description"]), + @r###" + @ add a file + │ + ~ + "###); } #[test] diff --git a/docs/config.md b/docs/config.md index 6ff3b99addf..6c4ae7846ea 100644 --- a/docs/config.md +++ b/docs/config.md @@ -2,7 +2,6 @@ These are the config settings available to jj/Jujutsu. - ## Config files and TOML `jj` loads several types of config settings: @@ -11,11 +10,11 @@ These are the config settings available to jj/Jujutsu. `cli/src/config/` directory in `jj`'s source repo. - The user settings. These can be edited with `jj config edit --user`. User -settings are located in [the user config file], which can be found with `jj + settings are located in [the user config file], which can be found with `jj config path --user`. - The repo settings. These can be edited with `jj config edit --repo` and are -located in `.jj/repo/config.toml`. + located in `.jj/repo/config.toml`. - Settings [specified in the command-line](#specifying-config-on-the-command-line). @@ -35,6 +34,7 @@ The first thing to remember is that the value of a setting (the part to the right of the `=` sign) should be surrounded in quotes if it's a string. ### Dotted style and headings + In TOML, anything under a heading can be dotted instead. For example, `user.name = "YOUR NAME"` is equivalent to: @@ -66,7 +66,6 @@ then use whichever suits you in your config. If you mix dotted keys and headings That's probably enough TOML to keep you out of trouble but the [syntax guide] is very short if you ever need to check. - ## User settings ```toml @@ -99,15 +98,15 @@ colors.commit_id = "green" The following colors are available: -* black -* red -* green -* yellow -* blue -* magenta -* cyan -* white -* default +- black +- red +- green +- yellow +- blue +- magenta +- cyan +- white +- default All of them but "default" come in a bright version too, e.g. "bright red". The "default" color can be used to override a color defined by a parent style @@ -215,7 +214,7 @@ immutable even if the set is empty. ### Default revisions to log -You can configure the revisions `jj log` without `-r` should show. +You can configure the revisions `jj log` would show when neither `-r` nor any paths are specified. ```toml # Show commits that are not in `main@origin` @@ -234,10 +233,11 @@ ui.graph.style = "square" The symbols used to represent commits or operations can be customized via templates. - * `templates.log_node` for commits (with `Option` keywords) - * `templates.op_log_node` for operations (with `Operation` keywords) +- `templates.log_node` for commits (with `Option` keywords) +- `templates.op_log_node` for operations (with `Operation` keywords) For example: + ```toml [templates] log_node = ''' @@ -416,7 +416,7 @@ Obviously, you would only set one line, don't copy them all in! ## Editing diffs -The `ui.diff-editor` setting affects the tool used for editing diffs (e.g. `jj +The `ui.diff-editor` setting affects the tool used for editing diffs (e.g. `jj split`, `jj squash -i`). The default is the special value `:builtin`, which launches a built-in TUI tool (known as [scm-diff-editor]) to edit the diff in your terminal. @@ -476,7 +476,6 @@ experience, you can follow [instructions from the Wiki] to configure the [DirDiff Vim plugin] and/or the [vimtabdiff Python script]. [instructions from the Wiki]: https://github.com/martinvonz/jj/wiki/Vim#using-vim-as-a-diff-tool - [DirDiff Vim plugin]: https://github.com/will133/vim-dirdiff [vimtabdiff Python script]: https://github.com/balki/vimtabdiff @@ -552,7 +551,7 @@ conflict is considered fully resolved when there are no conflict markers left. ## Commit Signing -`jj` can be configured to sign and verify the commits it creates using either +`jj` can be configured to sign and verify the commits it creates using either GnuPG or SSH signing keys. To do this you need to configure a signing backend. @@ -603,8 +602,8 @@ signing.backends.ssh.program = "/path/to/ssh-keygen" When verifying commit signatures the ssh backend needs to be provided with an allowed-signers file containing the public keys of authors whose signatures you want to be able to verify. -You can find the format for this file in the -[ssh-keygen man page](https://man.openbsd.org/ssh-keygen#ALLOWED_SIGNERS). This can be provided +You can find the format for this file in the +[ssh-keygen man page](https://man.openbsd.org/ssh-keygen#ALLOWED_SIGNERS). This can be provided as follows: ```toml