diff --git a/CHANGELOG.md b/CHANGELOG.md index 41eb7c2442..1d149c8f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `jj commit` accepts an optional list of paths indicating a subset of files to include in the parent revision. +* `jj commit` accepts the `--interactive` flag. + ### Fixed bugs ## [0.9.0] - 2023-09-06 diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 43bc5e623d..ded9249c50 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -469,6 +469,9 @@ struct DescribeArgs { #[derive(clap::Args, Clone, Debug)] #[command(visible_aliases=&["ci"])] struct CommitArgs { + /// Interactively choose which changes to include in the first commit + #[arg(short, long)] + interactive: bool, /// The change description to use (don't open editor) #[arg(long = "message", short, value_name = "MESSAGE")] message_paragraphs: Vec, @@ -2141,7 +2144,24 @@ fn cmd_commit(ui: &mut Ui, command: &CommandHelper, args: &CommitArgs) -> Result let matcher = workspace_command.matcher_from_values(&args.paths)?; let mut tx = workspace_command.start_transaction(&format!("commit {}", commit.id().hex())); let base_tree = merge_commit_trees(tx.repo(), &commit.parents())?; - let tree_id = tx.select_diff(ui, &base_tree, &commit.tree()?, matcher.as_ref(), "", false)?; + let instructions = format!( + "\ +You are making a partial commit from the changes in: {} + +The diff initially shows all changes. Adjust the right side until it shows the +contents you want for the new commit. The remainder will stay in the working +copy. +", + tx.format_commit_summary(&commit) + ); + let tree_id = tx.select_diff( + ui, + &base_tree, + &commit.tree()?, + matcher.as_ref(), + &instructions, + args.interactive, + )?; let middle_tree = tx.repo().store().get_root_tree(&tree_id)?; if !args.paths.is_empty() && middle_tree.id() == base_tree.id() { writeln!(