diff --git a/CHANGELOG.md b/CHANGELOG.md index 90379bef6b..c3cba8ab47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 usual behavior where commits that became unreachable in the Git repo are abandoned ([#2504](https://github.com/martinvonz/jj/pull/2504)). +* `jj rebase` now takes the flag `--skip-empty`, which doesn't copy over commits + that would become empty after a rebase. + ### Fixed bugs diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index 5e65fb1d8e..a98c24adea 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -143,6 +143,11 @@ pub(crate) struct RebaseArgs { /// commit) #[arg(long, short, required = true)] destination: Vec, + + #[arg(long)] + /// If true, when rebasing would produce an empty commit, the commit is skipped. + skip_empty: bool, + /// Deprecated. Please prefix the revset with `all:` instead. #[arg(long, short = 'L', hide = true)] allow_large_revsets: bool, @@ -162,8 +167,10 @@ Please use `jj rebase -d 'all:x|y'` instead of `jj rebase --allow-large-revsets } let rebase_options = RebaseOptions { - // TODO: Add a command-line flag for this. - empty: EmptyBehaviour::Keep, + empty: match args.skip_empty { + true => EmptyBehaviour::AbandonAllEmpty, + false => EmptyBehaviour::Keep, + }, }; let mut workspace_command = command.workspace_helper(ui)?; let new_parents = cli_util::resolve_all_revs(&workspace_command, ui, &args.destination)?