mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-19 10:44:58 +00:00
cli: add ui.always-allow-large-revsets
option
This lets users use "large" revsets in commands such as `jj rebase`, without needing the `all:` modifier. Signed-off-by: Austin Seipp <aseipp@pobox.com> Change-Id: Ica80927324f3d634413d3cc79fbc73057ccefd8a
This commit is contained in:
parent
2cf1c34f58
commit
db14f33170
6 changed files with 57 additions and 2 deletions
|
@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* Commit objects in templates now have a `mine() -> Boolean` method analog to the same function in revsets.
|
||||
It evaluates to true if the email of the commit author matches the current `user.email`.
|
||||
|
||||
* A new config option `ui.always-allow-large-revsets` has been added to
|
||||
allow large revsets expressions in some commands, without the `all:` prefix.
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
## [0.16.0] - 2024-04-03
|
||||
|
|
|
@ -775,7 +775,10 @@ impl WorkspaceCommandHelper {
|
|||
let (expression, modifier) = self.parse_revset_with_modifier(revision_arg)?;
|
||||
let all = match modifier {
|
||||
Some(RevsetModifier::All) => true,
|
||||
None => false,
|
||||
None => self
|
||||
.settings
|
||||
.config()
|
||||
.get_bool("ui.always-allow-large-revsets")?,
|
||||
};
|
||||
if all {
|
||||
for commit in expression.evaluate_to_commits()? {
|
||||
|
|
|
@ -41,6 +41,11 @@
|
|||
"description": "Whether to allow initializing a repo with the native backend",
|
||||
"default": false
|
||||
},
|
||||
"always-allow-large-revsets": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to allow large revsets to be used in all commands without the `all:` modifier",
|
||||
"default": false
|
||||
},
|
||||
"default-command": {
|
||||
"type": "string",
|
||||
"description": "Default command to run when no explicit command is given",
|
||||
|
|
|
@ -5,11 +5,11 @@ amend = ["squash"]
|
|||
co = ["checkout"]
|
||||
unamend = ["unsquash"]
|
||||
|
||||
|
||||
[format]
|
||||
tree-level-conflicts = true
|
||||
|
||||
[ui]
|
||||
always-allow-large-revsets = false
|
||||
diff-instructions = true
|
||||
paginate = "auto"
|
||||
pager = { command = ["less", "-FRX"], env = { LESSCHARSET = "utf-8" } }
|
||||
|
|
|
@ -484,6 +484,8 @@ fn test_rebase_multiple_destinations() {
|
|||
zsuskuln d370aee1 b | b
|
||||
Hint: Prefix the expression with 'all:' to allow any number of revisions (i.e. 'all:b|c').
|
||||
"###);
|
||||
|
||||
// try with 'all:' and succeed
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-r", "a", "-d", "all:b|c"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @"");
|
||||
|
@ -496,6 +498,26 @@ fn test_rebase_multiple_destinations() {
|
|||
◉
|
||||
"###);
|
||||
|
||||
// undo and do it again, but with 'ui.always-allow-large-revsets'
|
||||
let (_, _) = test_env.jj_cmd_ok(&repo_path, &["undo"]);
|
||||
let (_, _) = test_env.jj_cmd_ok(
|
||||
&repo_path,
|
||||
&[
|
||||
"rebase",
|
||||
"--config-toml=ui.always-allow-large-revsets=true",
|
||||
"-r=a",
|
||||
"-d=b|c",
|
||||
],
|
||||
);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ a
|
||||
├─╮
|
||||
│ ◉ b
|
||||
@ │ c
|
||||
├─╯
|
||||
◉
|
||||
"###);
|
||||
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-r", "a", "-d", "b", "-d", "b"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: More than one revset resolved to revision d370aee184ba
|
||||
|
|
|
@ -326,6 +326,28 @@ Can be customized by the `format_short_signature()` template alias.
|
|||
'format_short_signature(signature)' = 'signature.username()'
|
||||
```
|
||||
|
||||
### Allow "large" revsets by default
|
||||
|
||||
Certain commands (such as `jj rebase`) can take multiple revset arguments, and
|
||||
each of these may resolve to one-or-many revisions. By default, `jj` will not
|
||||
allow revsets that resolve to more than one revision — a so-called "large
|
||||
revset" — and will ask you to confirm that you want to proceed by
|
||||
prefixing it with the `all:` modifier.
|
||||
|
||||
For instance, to add a new parent `abc` to the commit `xyz`, you may use `jj
|
||||
rebase`:
|
||||
|
||||
```
|
||||
jj rebase -r xyz -d "all:xyz-" -d "abc"
|
||||
```
|
||||
|
||||
`jj` requires the `all:` prefix for the above command. However, you may disable
|
||||
this behavior by setting `ui.always-allow-large-revsets` to `true`:
|
||||
|
||||
```toml
|
||||
ui.always-allow-large-revsets = true
|
||||
```
|
||||
|
||||
## Pager
|
||||
|
||||
The default pager is can be set via `ui.pager` or the `PAGER` environment
|
||||
|
|
Loading…
Reference in a new issue