Skip to content

Commit

Permalink
commands: add --interactive flag to jj split
Browse files Browse the repository at this point in the history
I am constantly explicitly running `jj split -i` because I expect the interactive flag to be there for consistency.
  • Loading branch information
arxanas committed Aug 22, 2023
1 parent 6f80c55 commit 67be758
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,14 @@ struct DiffeditArgs {
/// asked for a description only for the first part.
#[derive(clap::Args, Clone, Debug)]
struct SplitArgs {
/// Interactively choose which parts to split. This is the default if no
/// paths are provided.
#[arg(long, short)]
interactive: bool,
/// The revision to split
#[arg(long, short, default_value = "@")]
revision: RevisionArg,
/// Put these paths in the first commit and don't run the diff editor
/// Put these paths in the first commit
#[arg(value_hint = clap::ValueHint::AnyPath)]
paths: Vec<String>,
}
Expand Down Expand Up @@ -3058,15 +3062,19 @@ fn diff_summary_to_description(bytes: &[u8]) -> String {

#[instrument(skip_all)]
fn cmd_split(ui: &mut Ui, command: &CommandHelper, args: &SplitArgs) -> Result<(), CommandError> {
let SplitArgs { revision, paths } = args;
let SplitArgs {
interactive,
revision,
paths,
} = args;
let mut workspace_command = command.workspace_helper(ui)?;
let commit = workspace_command.resolve_single_rev(revision, ui)?;
workspace_command.check_rewritable(&commit)?;
let matcher = workspace_command.matcher_from_values(paths)?;
let mut tx =
workspace_command.start_transaction(&format!("split commit {}", commit.id().hex()));
let base_tree = merge_commit_trees(tx.repo(), &commit.parents())?;
let interactive = paths.is_empty();
let interactive = *interactive || paths.is_empty();
let instructions = format!(
"\
You are splitting a commit in two: {}
Expand Down

0 comments on commit 67be758

Please sign in to comment.