From 7057ce21830a4b8a6d31d0bef57a6efd44303354 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sat, 14 Jan 2023 21:59:31 -0800 Subject: [PATCH] Test that `jj abandon root`, specifying same revision twice --- tests/test_abandon_command.rs | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test_abandon_command.rs b/tests/test_abandon_command.rs index 1a2829af1..a66a567f3 100644 --- a/tests/test_abandon_command.rs +++ b/tests/test_abandon_command.rs @@ -108,6 +108,51 @@ fn test_rebase_branch_with_merge() { o a e?? o c d e?? "###); + + // Test abandoning the same commit twice directly + test_env.jj_cmd_success(&repo_path, &["undo"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["abandon", "b", "b"]); + // Note that the same commit is listed twice + insta::assert_snapshot!(stdout, @r###" + Abandoned the following commits: + 1394f625cbbd b + 1394f625cbbd b + "###); + insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" + @ e + |\ + o | d + o | c + | o a b + |/ + o + "###); + + // Test abandoning the same commit twice indirectly + test_env.jj_cmd_success(&repo_path, &["undo"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["abandon", "d:", "a:"]); + // Note that the same commit is listed twice + insta::assert_snapshot!(stdout, @r###" + Abandoned the following commits: + 5557ece3e631 e + b7c62f28ed10 d + 5557ece3e631 e + 1394f625cbbd b + 2443ea76b0b1 a + Working copy now at: af874bffee6e (no description set) + Added 0 files, modified 0 files, removed 4 files + "###); + insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" + @ + | o c d e?? + |/ + o a b e?? + "###); + + let stderr = test_env.jj_cmd_failure(&repo_path, &["abandon", "root"]); + insta::assert_snapshot!(stderr, @r###" + Error: Cannot rewrite the root commit + "###); } fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {