From 18179cda3fc333b711a884a6a59dc09ffeec2ec8 Mon Sep 17 00:00:00 2001 From: Matt Stark Date: Wed, 3 Jul 2024 11:54:36 +1000 Subject: [PATCH] feat(rebase): Rename --skip-empty to --skip-emptied. This is based on @martinvonz's comment in #3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty. --- CHANGELOG.md | 2 ++ cli/src/commands/rebase.rs | 14 ++++++++++++-- cli/tests/cli-reference@.md.snap | 3 ++- cli/tests/test_rebase_command.rs | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cc374473a..20f26f36af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). move` to ensure that the target branch already exists. [#3584](https://github.com/martinvonz/jj/issues/3584) +* `jj rebase --skip-empty` has been renamed to `jj rebase --skip-emptied` + ### Deprecations * Replacing `-l` shorthand for `--limit` with `-n` in `jj log`, `jj op log` and `jj obslog`. diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index bd92e4feb3..622c0b01a2 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -188,12 +188,16 @@ pub(crate) struct RebaseArgs { )] insert_before: Vec, + /// Deprecated. Use --skip-emptied instead. + #[arg(long, conflicts_with = "revisions")] + skip_empty: bool, + /// If true, when rebasing would produce an empty commit, the commit is /// abandoned. It will not be abandoned if it was already empty before the /// rebase. Will never skip merge commits with multiple non-empty /// parents. #[arg(long, conflicts_with = "revisions")] - skip_empty: bool, + skip_emptied: bool, /// Deprecated. Please prefix the revset with `all:` instead. #[arg(long, short = 'L', hide = true)] @@ -213,8 +217,14 @@ Please use `jj rebase -d 'all:x|y'` instead of `jj rebase --allow-large-revsets )); } + if args.skip_empty { + return Err(user_error( + "--skip-empty is deprecated, and has been renamed to --skip-emptied.", + )); + } + let rebase_options = RebaseOptions { - empty: match args.skip_empty { + empty: match args.skip_emptied { true => EmptyBehaviour::AbandonNewlyEmpty, false => EmptyBehaviour::Keep, }, diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index 6d23499cc5..1a9b2e675d 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1540,7 +1540,8 @@ commit. This is true in general; it is not specific to this command. * `-B`, `--insert-before ` — The revision(s) to insert before (can be repeated to create a merge commit) Only works with `-r`. -* `--skip-empty` — If true, when rebasing would produce an empty commit, the commit is abandoned. It will not be abandoned if it was already empty before the rebase. Will never skip merge commits with multiple non-empty parents +* `--skip-empty` — Deprecated. Use --skip-emptied instead +* `--skip-emptied` — If true, when rebasing would produce an empty commit, the commit is abandoned. It will not be abandoned if it was already empty before the rebase. Will never skip merge commits with multiple non-empty parents diff --git a/cli/tests/test_rebase_command.rs b/cli/tests/test_rebase_command.rs index b7ae47fbc3..8e4ca1c858 100644 --- a/cli/tests/test_rebase_command.rs +++ b/cli/tests/test_rebase_command.rs @@ -2236,7 +2236,7 @@ fn test_rebase_revisions_after_before() { } #[test] -fn test_rebase_skip_empty() { +fn test_rebase_skip_emptied() { let test_env = TestEnvironment::default(); test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); let repo_path = test_env.env_root().join("repo"); @@ -2259,7 +2259,7 @@ fn test_rebase_skip_empty() { ◉ "###); - let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-d=b", "--skip-empty"]); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-d=b", "--skip-emptied"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" Rebased 3 commits