summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/t09-tree.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/tests/t09-tree.c b/tests/t09-tree.c
index 6c1b2e643..e4252dbca 100644
--- a/tests/t09-tree.c
+++ b/tests/t09-tree.c
@@ -29,6 +29,36 @@
static const char *tree_oid = "1810dff58d8a660512d4832e740f692884338ccd";
+#if 0
+static int print_tree(git_repository *repo, const git_oid *tree_oid, int depth)
+{
+ static const char *indent = " ";
+ git_tree *tree;
+ unsigned int i;
+
+ if (git_tree_lookup(&tree, repo, tree_oid) < GIT_SUCCESS)
+ return GIT_ERROR;
+
+ for (i = 0; i < git_tree_entrycount(tree); ++i) {
+ const git_tree_entry *entry = git_tree_entry_byindex(tree, i);
+ char entry_oid[40];
+
+ git_oid_fmt(entry_oid, &entry->oid);
+ printf("%.*s%o [%.*s] %s\n", depth*2, indent, entry->attr, 40, entry_oid, entry->filename);
+
+ if (entry->attr == S_IFDIR) {
+ if (print_tree(repo, &entry->oid, depth + 1) < GIT_SUCCESS) {
+ git_tree_close(tree);
+ return GIT_ERROR;
+ }
+ }
+ }
+
+ git_tree_close(tree);
+ return GIT_SUCCESS;
+}
+#endif
+
BEGIN_TEST(read0, "acces randomly the entries on a loaded tree")
git_oid id;
git_repository *repo;
@@ -55,7 +85,7 @@ BEGIN_TEST(read1, "read a tree from the repository")
git_oid id;
git_repository *repo;
git_tree *tree;
- git_tree_entry *entry;
+ const git_tree_entry *entry;
git_object *obj;
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
@@ -80,10 +110,27 @@ BEGIN_TEST(read1, "read a tree from the repository")
git_repository_free(repo);
END_TEST
+#if 0
+BEGIN_TEST(write0, "write a tree from an index")
+ git_repository *repo;
+ git_index *index;
+ git_oid tree_oid;
+
+ must_pass(git_repository_open(&repo, "/tmp/redtmp/.git"));
+ must_pass(git_repository_index(&index, repo));
+
+ must_pass(git_tree_create_fromindex(&tree_oid, index));
+ must_pass(print_tree(repo, &tree_oid, 0));
+
+ git_repository_free(repo);
+END_TEST
+#endif
+
BEGIN_SUITE(tree)
+ //ADD_TEST(print0);
ADD_TEST(read0);
ADD_TEST(read1);
-// ADD_TEST(write0); /* TODO THREADSAFE */
-// ADD_TEST(write1);
+ //ADD_TEST(write0);
+ //ADD_TEST(write1);
END_SUITE