summaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-11-05 03:20:17 +0200
committerVicent Marti <tanoku@gmail.com>2010-11-05 03:20:17 +0200
commit1795f87952a68155a618523799f70473483c7265 (patch)
tree239c2fef7674cc0407523be0a250b563361efc6b /src/tree.c
parent1714826fa08ad8612b720c8fdea636a4fc49c480 (diff)
downloadlibgit2-1795f87952a68155a618523799f70473483c7265.tar.gz
Improve error handling
All initialization functions now return error codes instead of pointers. Error codes are now properly propagated on most functions. Several new and more specific error codes have been added in common.h Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/tree.c b/src/tree.c
index 526f9dc31..9dd407d7e 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -93,21 +93,11 @@ void git_tree__free(git_tree *tree)
free(tree);
}
-git_tree *git_tree_new(git_repository *repo)
-{
- return (git_tree *)git_object_new(repo, GIT_OBJ_TREE);
-}
-
const git_oid *git_tree_id(git_tree *c)
{
return git_object_id((git_object *)c);
}
-git_tree *git_tree_lookup(git_repository *repo, const git_oid *id)
-{
- return (git_tree *)git_repository_lookup(repo, id, GIT_OBJ_TREE);
-}
-
void git_tree_entry_set_attributes(git_tree_entry *entry, int attr)
{
assert(entry && entry->owner);
@@ -151,10 +141,10 @@ const git_oid *git_tree_entry_id(git_tree_entry *entry)
return &entry->oid;
}
-git_object *git_tree_entry_2object(git_tree_entry *entry)
+int git_tree_entry_2object(git_object **object_out, git_tree_entry *entry)
{
- assert(entry);
- return git_repository_lookup(entry->owner->object.repo, &entry->oid, GIT_OBJ_ANY);
+ assert(entry && object_out);
+ return git_repository_lookup(object_out, entry->owner->object.repo, &entry->oid, GIT_OBJ_ANY);
}
git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename)
@@ -253,7 +243,7 @@ int git_tree__writeback(git_tree *tree, git_odb_source *src)
assert(tree && src);
if (tree->entries == NULL)
- return GIT_ERROR;
+ return GIT_EMISSINGOBJDATA;
entry_resort(tree);