diff --git a/cli/src/commands/diff.rs b/cli/src/commands/diff.rs index 446c796c49..77b933ce5e 100644 --- a/cli/src/commands/diff.rs +++ b/cli/src/commands/diff.rs @@ -56,6 +56,9 @@ pub(crate) struct DiffArgs { /// Show changes to this revision #[arg(long, short, conflicts_with = "revision", add = ArgValueCandidates::new(complete::all_revisions))] to: Option, + /// Restrict the diff to the paths specified in [fileset-aliases.{}] + #[arg(long, short = 'P', conflicts_with = "paths")] + fileset_alias: Option, /// Restrict the diff to these paths #[arg(value_hint = clap::ValueHint::AnyPath)] paths: Vec, @@ -71,7 +74,14 @@ pub(crate) fn cmd_diff( ) -> Result<(), CommandError> { let workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo(); - let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?; + let fileset_expression = if let Some(alias) = &args.fileset_alias { + let fileset = workspace_command + .settings() + .get_string(&format!("fileset-aliases.{}", alias))?; + workspace_command.parse_file_patterns(ui, &[fileset])? + } else { + workspace_command.parse_file_patterns(ui, &args.paths)? + }; let matcher = fileset_expression.to_matcher(); let resolve_revision = |r: &Option| { workspace_command.resolve_single_rev(ui, r.as_ref().unwrap_or(&RevisionArg::AT))