diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 3daaf3395d..d48f8ad975 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -772,8 +772,10 @@ impl WorkspaceCommandHelper { let mut all_commits = IndexSet::new(); for revision_str in revision_args { let (expression, all) = self.parse_revset_with_all_prefix(revision_str)?; - let commits = if all { - expression.evaluate_to_commits()?.try_collect()? + if all { + for commit in expression.evaluate_to_commits()? { + all_commits.insert(commit?); + } } else { let should_hint_about_all_prefix = true; let commit = revset_util::evaluate_revset_to_single_commit( @@ -782,9 +784,6 @@ impl WorkspaceCommandHelper { || self.commit_summary_template(), should_hint_about_all_prefix, )?; - vec![commit] - }; - for commit in commits { let commit_hash = short_commit_hash(commit.id()); if !all_commits.insert(commit) { return Err(user_error(format!( diff --git a/cli/tests/test_new_command.rs b/cli/tests/test_new_command.rs index 18de961231..ed5e20543e 100644 --- a/cli/tests/test_new_command.rs +++ b/cli/tests/test_new_command.rs @@ -137,6 +137,13 @@ fn test_new_merge() { insta::assert_snapshot!(stderr, @r###" Error: More than one revset resolved to revision 3a44e52b073c "###); + // if prefixed with all:, duplicates are allowed + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["new", "@", "all:visible_heads()"]); + insta::assert_snapshot!(stdout, @""); + insta::assert_snapshot!(stderr, @r###" + Working copy now at: xznxytkn dddeb489 (empty) (no description set) + Parent commit : wqnwkozp 3a44e52b (empty) (no description set) + "###); // merge with root let stderr = test_env.jj_cmd_failure(&repo_path, &["new", "@", "root()"]);