mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 22:39:38 +00:00
test: ensure we can round-trip a written tree
Read a tree into an index, write the index, then re-open the index and ensure that we are treesame to the original.
This commit is contained in:
parent
80745b1256
commit
8be49681a6
@ -103,3 +103,26 @@ void test_index_read_index__produces_treesame_indexes(void)
|
|||||||
roundtrip_with_read_index("fd093bff70906175335656e6ce6ae05783708765");
|
roundtrip_with_read_index("fd093bff70906175335656e6ce6ae05783708765");
|
||||||
roundtrip_with_read_index("ae90f12eea699729ed24555e40b9fd669da12a12");
|
roundtrip_with_read_index("ae90f12eea699729ed24555e40b9fd669da12a12");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_index_read_index__read_and_writes(void)
|
||||||
|
{
|
||||||
|
git_oid tree_id, new_tree_id;
|
||||||
|
git_tree *tree;
|
||||||
|
git_index *tree_index, *new_index;
|
||||||
|
|
||||||
|
cl_git_pass(git_oid_fromstr(&tree_id, "ae90f12eea699729ed24555e40b9fd669da12a12"));
|
||||||
|
cl_git_pass(git_tree_lookup(&tree, _repo, &tree_id));
|
||||||
|
cl_git_pass(git_index_new(&tree_index));
|
||||||
|
cl_git_pass(git_index_read_tree(tree_index, tree));
|
||||||
|
cl_git_pass(git_index_read_index(_index, tree_index));
|
||||||
|
cl_git_pass(git_index_write(_index));
|
||||||
|
|
||||||
|
cl_git_pass(git_index_open(&new_index, git_index_path(_index)));
|
||||||
|
cl_git_pass(git_index_write_tree_to(&new_tree_id, new_index, _repo));
|
||||||
|
|
||||||
|
cl_assert_equal_oid(&tree_id, &new_tree_id);
|
||||||
|
|
||||||
|
git_tree_free(tree);
|
||||||
|
git_index_free(tree_index);
|
||||||
|
git_index_free(new_index);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user