Skip to content

Commit

Permalink
cli: simplify check for non-empty revisions with/without "all:"
Browse files Browse the repository at this point in the history
If "all:" is specified, an empty set should be allowed within that expression.
So the additional check we need here is to ensure that the resulting set is not
empty.
  • Loading branch information
yuja committed Mar 30, 2024
1 parent 05242c9 commit db15571
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1658,9 +1658,6 @@ pub fn resolve_multiple_nonempty_revsets_default_single(
let mut all_commits = IndexSet::new();
for revision_str in revisions {
let commits = workspace_command.resolve_revset_default_single(revision_str)?;
if commits.is_empty() {
return Err(user_error("Empty revision set"));
}
for commit in commits {
let commit_hash = short_commit_hash(commit.id());
if !all_commits.insert(commit) {
Expand All @@ -1670,7 +1667,11 @@ pub fn resolve_multiple_nonempty_revsets_default_single(
}
}
}
Ok(all_commits)
if all_commits.is_empty() {
Err(user_error("Empty revision set"))
} else {
Ok(all_commits)
}
}

pub fn update_working_copy(
Expand Down
4 changes: 0 additions & 4 deletions cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ Please use `jj new 'all:x|y'` instead of `jj new --allow-large-revsets x y`.",
));
}
let mut workspace_command = command.workspace_helper(ui)?;
assert!(
!args.revisions.is_empty(),
"expected a non-empty list from clap"
);
let target_commits =
resolve_multiple_nonempty_revsets_default_single(&workspace_command, &args.revisions)?
.into_iter()
Expand Down

0 comments on commit db15571

Please sign in to comment.