summaryrefslogtreecommitdiff
path: root/tests/t09-tree.c
diff options
context:
space:
mode:
authorShuhei Tanuma <shuhei.tanuma@gmail.com>2011-04-06 02:22:24 +0900
committerVicent Marti <tanoku@gmail.com>2011-04-08 03:30:47 +0300
commit98ac67808559e8c2238a855feb6fedfc4b956984 (patch)
tree033471204862ab70f4a42f51823568b2fb399c5a /tests/t09-tree.c
parent5868cd02b7ff21f848b64ead3d7b0aa62155046e (diff)
downloadlibgit2-98ac67808559e8c2238a855feb6fedfc4b956984.tar.gz
fix git_treebuilder_insert probrem.
couldn't add new entry when inserting new one with `git_treebuilder_insert`.
Diffstat (limited to 'tests/t09-tree.c')
-rw-r--r--tests/t09-tree.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/t09-tree.c b/tests/t09-tree.c
index e4252dbca..1ccce8ed6 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,36 @@ 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_index *index;
+ git_treebuilder *builder;
+ git_tree *tree;
+ git_oid id;
+ git_oid bid;
+ git_oid rid;
+
+ must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
+ git_oid_mkstr(&id, first_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));
+
+ char out[41];
+ git_oid_to_string(out,41,&rid);
+ must_pass(strcmp(out,second_tree));
+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