diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index 040009517..af6a189fe 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use clap::parser::ValueSource; use jj_lib::commit::Commit; use jj_lib::matchers::Matcher; use jj_lib::object_id::ObjectId; @@ -42,8 +41,9 @@ use crate::ui::Ui; /// commit. This is true in general; it is not specific to this command. #[derive(clap::Args, Clone, Debug)] pub(crate) struct SquashArgs { - #[arg(long, short, default_value = "@")] - revision: RevisionArg, + /// Revision to squash into its parent (default: @) + #[arg(long, short)] + revision: Option, /// The description to use for squashed revision (don't open editor) #[arg(long = "message", short, value_name = "MESSAGE")] message_paragraphs: Vec, @@ -65,7 +65,7 @@ pub(crate) fn cmd_squash( args: &SquashArgs, ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let commit = workspace_command.resolve_single_rev(&args.revision)?; + let commit = workspace_command.resolve_single_rev(args.revision.as_deref().unwrap_or("@"))?; workspace_command.check_rewritable([&commit])?; let parents = commit.parents(); if parents.len() != 1 { @@ -103,8 +103,7 @@ from the source will be moved into the parent. } if let [only_path] = &args.paths[..] { - let (_, matches) = command.matches().subcommand().unwrap(); - if matches.value_source("revision").unwrap() == ValueSource::DefaultValue + if args.revision.is_none() && revset::parse( only_path, &tx.base_workspace_helper().revset_parse_context(), diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index b825dc6e0..c634110b0 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1700,9 +1700,7 @@ If a working-copy commit gets abandoned, it will be given a new, empty commit. T ###### **Options:** -* `-r`, `--revision ` - - Default value: `@` +* `-r`, `--revision ` — Revision to squash into its parent (default: @) * `-m`, `--message ` — The description to use for squashed revision (don't open editor) * `-i`, `--interactive` — Interactively choose which parts to squash