diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index fe3a7a184..9ccafb56b 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -421,6 +421,57 @@ fn test_git_push_changes() { Branch changes to push to origin: Force branch push-yostqsxwqrlt from 48d8c7948133 to b5f030322b1d "###); + + // FIXME: specifying the same branch with --change/--branch doesn't break things + std::fs::write(workspace_root.join("file"), "modified4").unwrap(); + let (stdout, stderr) = test_env.jj_cmd_ok( + &workspace_root, + &["git", "push", "-c=@", "-b=push-yostqsxwqrlt"], + ); + insta::assert_snapshot!(stdout, @""); + insta::assert_snapshot!(stderr, @r###" + Branch changes to push to origin: + Force branch push-yostqsxwqrlt from b5f030322b1d to 4df62cec2ee4 + Force branch push-yostqsxwqrlt from b5f030322b1d to 4df62cec2ee4 + "###); + + // FIXME: try again with --change that moves the branch forward + std::fs::write(workspace_root.join("file"), "modified5").unwrap(); + test_env.jj_cmd_ok( + &workspace_root, + &[ + "branch", + "set", + "-r=@-", + "--allow-backwards", + "push-yostqsxwqrlt", + ], + ); + let stdout = test_env.jj_cmd_success(&workspace_root, &["status"]); + insta::assert_snapshot!(stdout, @r###" + Working copy changes: + M file + Working copy : yostqsxw 3e2ce808 bar + Parent commit: yqosqzyt fa16a141 push-yostqsxwqrlt* push-yqosqzytrlsw | foo + "###); + let (stdout, stderr) = test_env.jj_cmd_ok( + &workspace_root, + &["git", "push", "-c=@", "-b=push-yostqsxwqrlt"], + ); + insta::assert_snapshot!(stdout, @""); + insta::assert_snapshot!(stderr, @r###" + Branch changes to push to origin: + Force branch push-yostqsxwqrlt from 4df62cec2ee4 to fa16a14170fb + Force branch push-yostqsxwqrlt from 4df62cec2ee4 to 3e2ce808759b + "###); + let stdout = test_env.jj_cmd_success(&workspace_root, &["status"]); + insta::assert_snapshot!(stdout, @r###" + Working copy changes: + M file + Working copy : yostqsxw 3e2ce808 push-yostqsxwqrlt | bar + Parent commit: yqosqzyt fa16a141 push-yqosqzytrlsw | foo + "###); + // Test changing `git.push-branch-prefix`. It causes us to push again. let (stdout, stderr) = test_env.jj_cmd_ok( &workspace_root, @@ -436,7 +487,7 @@ fn test_git_push_changes() { insta::assert_snapshot!(stderr, @r###" Creating branch test-yostqsxwqrlt for revision @ Branch changes to push to origin: - Add branch test-yostqsxwqrlt to b5f030322b1d + Add branch test-yostqsxwqrlt to 3e2ce808759b "###); }