diff --git a/CHANGELOG.md b/CHANGELOG.md index cca67bd3b..35b6234a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * The `tags()` revset function now takes an optional `pattern` argument, mirroring that of `bookmarks()`. +* Several commands now support `-f/-t` shorthands for `--from/--to`: + - `diff` + - `diffedit` + - `interdiff` + - `op diff` + - `restore` + ### Fixed bugs * `jj config unset ` no longer removes a table (such as `[ui]`.) diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index 244cc4f4c..446c796c4 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -51,10 +51,10 @@ pub(crate) struct DiffArgs { #[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))] revision: Option, /// Show changes from this revision - #[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))] + #[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))] from: Option, /// Show changes to this revision - #[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))] + #[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))] to: Option, /// Restrict the diff to these paths #[arg(value_hint = clap::ValueHint::AnyPath)] diff --git a/cli/src/commands/diffedit.rs b/cli/src/commands/diffedit.rs index 75a4fabf5..89ee99b5d 100644 --- a/cli/src/commands/diffedit.rs +++ b/cli/src/commands/diffedit.rs @@ -55,12 +55,20 @@ pub(crate) struct DiffeditArgs { /// Show changes from this revision /// /// Defaults to @ if --to is specified. - #[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))] + #[arg( + long, short, + conflicts_with = "revision", + add = ArgValueCandidates::new(complete::all_revisions), + )] from: Option, /// Edit changes in this revision /// /// Defaults to @ if --from is specified. - #[arg(long, conflicts_with = "revision", add = ArgValueCandidates::new(complete::mutable_revisions))] + #[arg( + long, short, + conflicts_with = "revision", + add = ArgValueCandidates::new(complete::mutable_revisions), + )] to: Option, /// Specify diff editor to be used #[arg(long, value_name = "NAME")] diff --git a/cli/src/commands/interdiff.rs b/cli/src/commands/interdiff.rs index 75bc9439a..25d7e69ab 100644 --- a/cli/src/commands/interdiff.rs +++ b/cli/src/commands/interdiff.rs @@ -36,10 +36,10 @@ use crate::ui::Ui; #[command(mut_arg("ignore_space_change", |a| a.short('b')))] pub(crate) struct InterdiffArgs { /// Show changes from this revision - #[arg(long, add = ArgValueCandidates::new(complete::all_revisions))] + #[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))] from: Option, /// Show changes to this revision - #[arg(long, add = ArgValueCandidates::new(complete::all_revisions))] + #[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))] to: Option, /// Restrict the diff to these paths #[arg(value_hint = clap::ValueHint::AnyPath)] diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index 941cf4db5..ce88ec243 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -65,14 +65,14 @@ pub struct OperationDiffArgs { operation: Option, /// Show repository changes from this operation #[arg( - long, + long, short, conflicts_with = "operation", add = ArgValueCandidates::new(complete::operations), )] from: Option, /// Show repository changes to this operation #[arg( - long, + long, short, conflicts_with = "operation", add = ArgValueCandidates::new(complete::operations), )] diff --git a/cli/src/commands/restore.rs b/cli/src/commands/restore.rs index 42a68c525..9bc43c6a2 100644 --- a/cli/src/commands/restore.rs +++ b/cli/src/commands/restore.rs @@ -48,10 +48,10 @@ pub(crate) struct RestoreArgs { #[arg(value_hint = clap::ValueHint::AnyPath)] paths: Vec, /// Revision to restore from (source) - #[arg(long, add = ArgValueCandidates::new(complete::all_revisions))] + #[arg(long, short, add = ArgValueCandidates::new(complete::all_revisions))] from: Option, /// Revision to restore into (destination) - #[arg(long, add = ArgValueCandidates::new(complete::mutable_revisions))] + #[arg(long, short, add = ArgValueCandidates::new(complete::mutable_revisions))] to: Option, /// Undo the changes in a revision as compared to the merge of its parents. /// diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index e3da2f486..65f7a86ca 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1,6 +1,7 @@ --- source: cli/tests/test_generate_md_cli_help.rs description: "AUTO-GENERATED FILE, DO NOT EDIT. This cli reference is generated by a test as an `insta` snapshot. MkDocs includes this snapshot from docs/cli-reference.md." +snapshot_kind: text --- @@ -689,8 +690,8 @@ With the `--from` and/or `--to` options, shows the difference from/to the given * `-r`, `--revision ` — Show changes in this revision, compared to its parent(s) If the revision is a merge commit, this shows changes *from* the automatic merge of the contents of all of its parents *to* the contents of the revision itself. -* `--from ` — Show changes from this revision -* `--to ` — Show changes to this revision +* `-f`, `--from ` — Show changes from this revision +* `-t`, `--to ` — Show changes to this revision * `-s`, `--summary` — For each path, show only whether it was modified, added, or deleted * `--stat` — Show a histogram of the changes * `--types` — For each path, show only its type before and after @@ -729,10 +730,10 @@ See `jj restore` if you want to move entire files from one revision to another. * `-r`, `--revision ` — The revision to touch up Defaults to @ if neither --to nor --from are specified. -* `--from ` — Show changes from this revision +* `-f`, `--from ` — Show changes from this revision Defaults to @ if --to is specified. -* `--to ` — Edit changes in this revision +* `-t`, `--to ` — Edit changes in this revision Defaults to @ if --from is specified. * `--tool ` — Specify diff editor to be used @@ -1316,8 +1317,8 @@ This excludes changes from other commits by temporarily rebasing `--from` onto ` ###### **Options:** -* `--from ` — Show changes from this revision -* `--to ` — Show changes to this revision +* `-f`, `--from ` — Show changes from this revision +* `-t`, `--to ` — Show changes to this revision * `-s`, `--summary` — For each path, show only whether it was modified, added, or deleted * `--stat` — Show a histogram of the changes * `--types` — For each path, show only its type before and after @@ -1510,8 +1511,8 @@ Compare changes to the repository between two operations ###### **Options:** * `--operation ` — Show repository changes in this operation, compared to its parent -* `--from ` — Show repository changes from this operation -* `--to ` — Show repository changes to this operation +* `-f`, `--from ` — Show repository changes from this operation +* `-t`, `--to ` — Show repository changes to this operation * `--no-graph` — Don't show the graph, show a flat list of modified changes * `-p`, `--patch` — Show patch of modifications to changes @@ -1913,8 +1914,8 @@ See `jj diffedit` if you'd like to restore portions of files rather than entire ###### **Options:** -* `--from ` — Revision to restore from (source) -* `--to ` — Revision to restore into (destination) +* `-f`, `--from ` — Revision to restore from (source) +* `-t`, `--to ` — Revision to restore into (destination) * `-c`, `--changes-in ` — Undo the changes in a revision as compared to the merge of its parents. This undoes the changes that can be seen with `jj diff -r REVISION`. If `REVISION` only has a single parent, this option is equivalent to `jj restore --to REVISION --from REVISION-`. diff --git a/cli/tests/test_global_opts.rs b/cli/tests/test_global_opts.rs index fc469e541..6844e45ca 100644 --- a/cli/tests/test_global_opts.rs +++ b/cli/tests/test_global_opts.rs @@ -642,15 +642,15 @@ fn test_help() { let test_env = TestEnvironment::default(); let stdout = test_env.jj_cmd_success(test_env.env_root(), &["diffedit", "-h"]); - insta::assert_snapshot!(stdout, @r#" + insta::assert_snapshot!(stdout, @r" Touch up the content changes in a revision with a diff editor Usage: jj diffedit [OPTIONS] Options: -r, --revision The revision to touch up - --from Show changes from this revision - --to Edit changes in this revision + -f, --from Show changes from this revision + -t, --to Edit changes in this revision --tool Specify diff editor to be used --restore-descendants Preserve the content (not the diff) when rebasing descendants -h, --help Print help (see more with '--help') @@ -665,7 +665,7 @@ fn test_help() { --quiet Silence non-primary command output --no-pager Disable the pager --config-toml Additional configuration options (can be repeated) - "#); + "); } #[test]