From b21a123bc8947e51f84d498e78c952d8511a25bc Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 12 Sep 2022 18:45:16 +0900 Subject: [PATCH] cli: ensure rebase destinations are unique and not form a merge with root --- src/commands.rs | 6 +----- tests/test_rebase_command.rs | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index f254e9714..c9a829a88 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4071,11 +4071,7 @@ fn cmd_merge(ui: &mut Ui, command: &CommandHelper, args: &NewArgs) -> Result<(), fn cmd_rebase(ui: &mut Ui, command: &CommandHelper, args: &RebaseArgs) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; - let mut new_parents = vec![]; - for revision_str in &args.destination { - let destination = workspace_command.resolve_single_rev(revision_str)?; - new_parents.push(destination); - } + let new_parents = resolve_base_revs(&workspace_command, &args.destination)?; if let Some(rev_str) = &args.revision { rebase_revision(ui, &mut workspace_command, &new_parents, rev_str)?; } else if let Some(source_str) = &args.source { diff --git a/tests/test_rebase_command.rs b/tests/test_rebase_command.rs index 01c074ade..de2d9e04c 100644 --- a/tests/test_rebase_command.rs +++ b/tests/test_rebase_command.rs @@ -259,6 +259,8 @@ fn test_rebase_multiple_destinations() { |/ o "###); + + test_env.jj_cmd_failure(&repo_path, &["rebase", "-r", "a", "-d", "b", "-d", "root"]); } #[test]