| 26 | } |
| 27 | |
| 28 | fn init_fixture(root: &Path, home: &Path) { |
| 29 | let git = GitRepository::init(root).expect("init Git"); |
| 30 | git.set_head("refs/heads/main").expect("set main HEAD"); |
| 31 | fs::write(root.join("tracked.txt"), b"git-only\n").expect("write Git file"); |
| 32 | let mut index = git.index().expect("open index"); |
| 33 | index |
| 34 | .add_path(Path::new("tracked.txt")) |
| 35 | .expect("stage Git file"); |
| 36 | index.write().expect("write index"); |
| 37 | let tree_oid = index.write_tree().expect("write tree"); |
| 38 | let tree = git.find_tree(tree_oid).expect("find tree"); |
| 39 | let signature = Signature::now("Atomic Test", "atomic@example.com").expect("signature"); |
| 40 | git.commit(Some("HEAD"), &signature, &signature, "initial", &tree, &[]) |
| 41 | .expect("commit Git file"); |
| 42 | drop(tree); |
| 43 | drop(git); |
| 44 | |
| 45 | let output = atomic(root, home, &["init", "--view", "main"]); |
| 46 | assert!( |
| 47 | output.status.success(), |
| 48 | "atomic init failed:\nstdout:\n{}\nstderr:\n{}", |
| 49 | String::from_utf8_lossy(&output.stdout), |
| 50 | String::from_utf8_lossy(&output.stderr) |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | #[derive(Debug, Eq, PartialEq)] |
| 55 | enum SnapshotValue { |