]>
git.proxmox.com Git - libgit2.git/blob - tests/libgit2/index/read_tree.c
1 #include "clar_libgit2.h"
4 /* Test that reading and writing a tree is a no-op */
5 void test_index_read_tree__read_write_involution(void)
13 p_mkdir("read_tree", 0700);
15 cl_git_pass(git_repository_init(&repo
, "./read_tree", 0));
16 cl_git_pass(git_repository_index(&index
, repo
));
18 cl_assert(git_index_entrycount(index
) == 0);
20 p_mkdir("./read_tree/abc", 0700);
22 /* Sort order: '-' < '/' < '_' */
23 cl_git_mkfile("./read_tree/abc-d", NULL
);
24 cl_git_mkfile("./read_tree/abc/d", NULL
);
25 cl_git_mkfile("./read_tree/abc_d", NULL
);
27 cl_git_pass(git_index_add_bypath(index
, "abc-d"));
28 cl_git_pass(git_index_add_bypath(index
, "abc_d"));
29 cl_git_pass(git_index_add_bypath(index
, "abc/d"));
32 cl_git_pass(git_index_write_tree(&expected
, index
));
35 git_tree_lookup(&tree
, repo
, &expected
);
36 cl_git_pass(git_index_read_tree(index
, tree
));
39 cl_git_pass(git_index_write_tree(&tree_oid
, index
));
40 cl_assert_equal_oid(&expected
, &tree_oid
);
42 git_index_free(index
);
43 git_repository_free(repo
);
45 cl_fixture_cleanup("read_tree");