Skip to content

Commit

Permalink
Add a --skip-empty flag to rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
matts1 committed Nov 21, 2023
1 parent 7fe8640 commit 5cbd68c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
11 changes: 9 additions & 2 deletions cli/src/commands/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ pub(crate) struct RebaseArgs {
/// commit)
#[arg(long, short, required = true)]
destination: Vec<RevisionArg>,

#[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,
Expand All @@ -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)?
Expand Down

0 comments on commit 5cbd68c

Please sign in to comment.