summaryrefslogtreecommitdiff
path: root/tests/t09-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/t09-tree.c')
-rw-r--r--tests/t09-tree.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/t09-tree.c b/tests/t09-tree.c
index e4252dbca..bd88642fa 100644
--- a/tests/t09-tree.c
+++ b/tests/t09-tree.c
@@ -29,6 +29,10 @@
static const char *tree_oid = "1810dff58d8a660512d4832e740f692884338ccd";
+static const char *blob_oid = "fa49b077972391ad58037050f2a75f74e3671e92";
+static const char *first_tree = "181037049a54a1eb5fab404658a3a250b44335d7";
+static const char *second_tree = "f60079018b664e4e79329a7ef9559c8d9e0378d1";
+
#if 0
static int print_tree(git_repository *repo, const git_oid *tree_oid, int depth)
{
@@ -126,11 +130,33 @@ BEGIN_TEST(write0, "write a tree from an index")
END_TEST
#endif
+BEGIN_TEST(write2, "write a tree from a memory")
+ git_repository *repo;
+ git_treebuilder *builder;
+ git_tree *tree;
+ git_oid id, bid, rid, id2;
+
+ must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
+ git_oid_mkstr(&id, first_tree);
+ git_oid_mkstr(&id2, second_tree);
+ git_oid_mkstr(&bid, blob_oid);
+
+ //create a second tree from first tree using `git_treebuilder_insert` on REPOSITORY_FOLDER.
+ must_pass(git_tree_lookup(&tree, repo, &id));
+ must_pass(git_treebuilder_create(&builder, tree));
+ must_pass(git_treebuilder_insert(NULL,builder,"new.txt",&bid,0100644));
+ must_pass(git_treebuilder_write(&rid,repo,builder));
+
+ must_be_true(git_oid_cmp(&rid, &id2) == 0);
+ close_temp_repo(repo);
+END_TEST
+
BEGIN_SUITE(tree)
//ADD_TEST(print0);
ADD_TEST(read0);
ADD_TEST(read1);
//ADD_TEST(write0);
//ADD_TEST(write1);
+ ADD_TEST(write2);
END_SUITE