Skip to content

Commit bf2283f

Browse files
committed
cli: jj absorb warns when fileset doesn't exist
1 parent 050e175 commit bf2283f

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8585

8686
* Revsets now support logical operators in string patterns.
8787

88+
* All `jj` commands show a warning when the provided `fileset` expression
89+
doesn't match any files.
90+
8891
### Fixed bugs
8992

9093
* `jj metaedit --author-timestamp` twice with the same value no longer

cli/src/commands/absorb.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use tracing::instrument;
2222

2323
use crate::cli_util::CommandHelper;
2424
use crate::cli_util::RevisionArg;
25+
use crate::cli_util::print_unmatched_explicit_paths;
2526
use crate::cli_util::print_updated_commits;
2627
use crate::command_error::CommandError;
2728
use crate::complete;
@@ -81,14 +82,20 @@ pub(crate) fn cmd_absorb(
8182
.parse_union_revsets(ui, &args.into)?
8283
.resolve()?;
8384

84-
let matcher = workspace_command
85-
.parse_file_patterns(ui, &args.paths)?
86-
.to_matcher();
85+
let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?;
86+
let matcher = fileset_expression.to_matcher();
8787

8888
let repo = workspace_command.repo().as_ref();
89-
let source = AbsorbSource::from_commit(repo, source_commit)?;
89+
let source = AbsorbSource::from_commit(repo, source_commit.clone())?;
9090
let selected_trees = split_hunks_to_trees(repo, &source, &destinations, &matcher).block_on()?;
9191

92+
print_unmatched_explicit_paths(
93+
ui,
94+
&workspace_command,
95+
&fileset_expression,
96+
[&source_commit.tree()?],
97+
)?;
98+
9299
let path_converter = workspace_command.path_converter();
93100
for (path, reason) in selected_trees.skipped_paths {
94101
let ui_path = path_converter.format_file_path(&path);

cli/tests/test_absorb_command.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,10 @@ fn test_absorb_paths() {
810810
work_dir.write_file("file1", "1A\n");
811811
work_dir.write_file("file2", "1A\n");
812812

813-
let output = work_dir.run_jj(["absorb", "unknown"]);
813+
let output = work_dir.run_jj(["absorb", "nonexistent"]);
814814
insta::assert_snapshot!(output, @r"
815815
------- stderr -------
816+
Warning: No matching entries for paths: nonexistent
816817
Nothing changed.
817818
[EOF]
818819
");

0 commit comments

Comments
 (0)