Skip to content

Commit

Permalink
command: add --interactive flag to jj commit
Browse files Browse the repository at this point in the history
  • Loading branch information
arxanas committed Sep 17, 2023
1 parent 2fd80ab commit 1efcd29
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ struct DescribeArgs {
#[derive(clap::Args, Clone, Debug)]
#[command(visible_aliases=&["ci"])]
struct CommitArgs {
/// Interactively choose which changes to 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<String>,
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit 1efcd29

Please sign in to comment.