Hash :
1795f879
Author :
Date :
2010-11-05T03:20:17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#include "test_lib.h"
#include "test_helpers.h"
#include "commit.h"
#include <git/odb.h>
#include <git/commit.h>
#include <git/revwalk.h>
static const char *tree_oid = "1810dff58d8a660512d4832e740f692884338ccd";
BEGIN_TEST(tree_entry_access_test)
git_oid id;
git_repository *repo;
git_tree *tree;
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid);
must_pass(git_tree_lookup(&tree, repo, &id));
must_be_true(git_tree_entry_byname(tree, "README") != NULL);
must_be_true(git_tree_entry_byname(tree, "NOTEXISTS") == NULL);
must_be_true(git_tree_entry_byname(tree, "") == NULL);
must_be_true(git_tree_entry_byindex(tree, 0) != NULL);
must_be_true(git_tree_entry_byindex(tree, 2) != NULL);
must_be_true(git_tree_entry_byindex(tree, 3) == NULL);
must_be_true(git_tree_entry_byindex(tree, -1) == NULL);
git_repository_free(repo);
END_TEST
BEGIN_TEST(tree_read_test)
git_oid id;
git_repository *repo;
git_tree *tree;
git_tree_entry *entry;
git_object *obj;
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid);
must_pass(git_tree_lookup(&tree, repo, &id));
must_be_true(git_tree_entrycount(tree) == 3);
entry = git_tree_entry_byname(tree, "README");
must_be_true(entry != NULL);
must_be_true(strcmp(git_tree_entry_name(entry), "README") == 0);
must_pass(git_tree_entry_2object(&obj, entry));
git_repository_free(repo);
END_TEST