mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-26 22:10:52 +00:00
tests: demonstrate spurious branch conflict after git export
This is a test case for #463. It's not exactly the same case, but I'm confident that the root cause is the same (that the `.jj/repo/git_export_operation_id` doesn't include the git refs we just updated).
This commit is contained in:
parent
ec46ae11ad
commit
18a25a7c2b
1 changed files with 51 additions and 0 deletions
|
@ -568,6 +568,57 @@ fn test_export_refs_unborn_git_branch() {
|
|||
assert!(!git_repo.head_detached().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_export_import_sequence() {
|
||||
// Import a branch pointing to A, modify it in jj to point to B, export it,
|
||||
// modify it in git to point to C, then import it again. There should be no
|
||||
// conflict.
|
||||
let mut test_data = GitRepoData::create();
|
||||
let git_repo = test_data.git_repo;
|
||||
let mut tx = test_data.repo.start_transaction("test");
|
||||
let commit_a =
|
||||
create_random_commit(&test_data.settings, &test_data.repo).write_to_repo(tx.mut_repo());
|
||||
let commit_b =
|
||||
create_random_commit(&test_data.settings, &test_data.repo).write_to_repo(tx.mut_repo());
|
||||
let commit_c =
|
||||
create_random_commit(&test_data.settings, &test_data.repo).write_to_repo(tx.mut_repo());
|
||||
test_data.repo = tx.commit();
|
||||
|
||||
// Import the branch pointing to A
|
||||
git_repo
|
||||
.reference("refs/heads/main", git_id(&commit_a), true, "test")
|
||||
.unwrap();
|
||||
let mut tx = test_data.repo.start_transaction("test");
|
||||
git::import_refs(tx.mut_repo(), &git_repo).unwrap();
|
||||
test_data.repo = tx.commit();
|
||||
|
||||
// Modify the branch in jj to point to B
|
||||
let mut tx = test_data.repo.start_transaction("test");
|
||||
tx.mut_repo()
|
||||
.set_local_branch("main".to_string(), RefTarget::Normal(commit_b.id().clone()));
|
||||
test_data.repo = tx.commit();
|
||||
|
||||
// Export the branch to git
|
||||
assert_eq!(git::export_refs(&test_data.repo, &git_repo), Ok(()));
|
||||
|
||||
// Modify the branch in git to point to C
|
||||
git_repo
|
||||
.reference("refs/heads/main", git_id(&commit_c), true, "test")
|
||||
.unwrap();
|
||||
|
||||
// Import from git
|
||||
let mut tx = test_data.repo.start_transaction("test");
|
||||
git::import_refs(tx.mut_repo(), &git_repo).unwrap();
|
||||
// TODO: The branch should point to C, it shouldn't be a conflict
|
||||
assert_eq!(
|
||||
tx.mut_repo().view().get_local_branch("main"),
|
||||
Some(RefTarget::Conflict {
|
||||
removes: vec![commit_a.id().clone()],
|
||||
adds: vec![commit_b.id().clone(), commit_c.id().clone()],
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_init() {
|
||||
let settings = testutils::user_settings();
|
||||
|
|
Loading…
Reference in a new issue