ok/jj
1
0
Fork 0
forked from mirrors/jj

tests: demonstrate bug on undo after squash in colocated working copy

I think this is the same bug as reported in #922, just simplified a
bit further. The branches in the repo actually look good after the
`undo` operation, but the reverted `master` branch doesn't get
exported to the git repo even though our recorded `refs/heads/master`
in the repo was moved back. Then the next automatic import on `log`
notices that the `master` branch in the git repo still points to the
new commit, and that commit becomes visible again.
This commit is contained in:
Martin von Zweigbergk 2023-01-30 20:08:17 -08:00 committed by Martin von Zweigbergk
parent e3e7c17f52
commit 910c73a9ae

View file

@ -266,6 +266,49 @@ fn test_git_colocated_fetch_deleted_branch() {
"###);
}
#[test]
fn test_git_colocated_squash_undo() {
let test_env = TestEnvironment::default();
let repo_path = test_env.env_root().join("repo");
git2::Repository::init(&repo_path).unwrap();
test_env.jj_cmd_success(&repo_path, &["init", "--git-repo=."]);
test_env.jj_cmd_success(&repo_path, &["ci", "-m=A"]);
// Test the setup
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
@ 8e4fac809cbb 8f71e3b6a3be (no description set)
o 9a45c67d3e96 a86754f975f9 A master
o 000000000000 000000000000 (no description set)
"###);
test_env.jj_cmd_success(&repo_path, &["squash"]);
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
@ 0757f5ec8418 f0c12b0396d9 (no description set)
o 9a45c67d3e96 2f376ea1478c A master
o 000000000000 000000000000 (no description set)
"###);
test_env.jj_cmd_success(&repo_path, &["undo"]);
// TODO: There should be no divergence here; 2f376ea1478c should be hidden
// (#922)
insta::assert_snapshot!(get_log_output_divergence(&test_env, &repo_path), @r###"
o 9a45c67d3e96 2f376ea1478c A master !divergence!
| @ 8e4fac809cbb 8f71e3b6a3be (no description set)
| o 9a45c67d3e96 a86754f975f9 A !divergence!
|/
o 000000000000 000000000000 (no description set)
"###);
}
fn get_log_output_divergence(test_env: &TestEnvironment, repo_path: &Path) -> String {
test_env.jj_cmd_success(
repo_path,
&[
"log",
"-T",
r#"change_id.short() " " commit_id.short() " " description.first_line() " " branches if(divergent, " !divergence!")"#,
],
)
}
fn get_log_output(test_env: &TestEnvironment, workspace_root: &Path) -> String {
test_env.jj_cmd_success(
workspace_root,