diff options
author | Vicent Marti <tanoku@gmail.com> | 2010-08-12 18:45:31 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2010-08-12 18:49:04 +0200 |
commit | 003c26909451715cf36ea37ae4a6237813b4a25e (patch) | |
tree | 00f369a7a34eb7cbf3e2785c567ccaa618f8d40f /src/git/tree.h | |
parent | ff17642dc212bd345fda7dc213f08f8815c96841 (diff) | |
download | libgit2-003c26909451715cf36ea37ae4a6237813b4a25e.tar.gz |
Finish the tree object API
The interface for loading and parsing tree objects from a repository has
been completed with all the required accesor methods for attributes,
support for manipulating individual tree entries and a new unit test
t0901-readtree which tries to load and parse a tree object from a
repository.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/git/tree.h')
-rw-r--r-- | src/git/tree.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/git/tree.h b/src/git/tree.h index 95b233009..bd589ea11 100644 --- a/src/git/tree.h +++ b/src/git/tree.h @@ -14,6 +14,10 @@ */ GIT_BEGIN_DECL + +/** Representation of each one of the entries in a tree object. */ +typedef struct git_tree_entry git_tree_entry; + /** Representation of a tree object. */ typedef struct git_tree git_tree; @@ -35,6 +39,58 @@ GIT_EXTERN(git_tree *) git_tree_lookup(git_repository *repo, const git_oid *id); */ GIT_EXTERN(const git_oid *) git_tree_id(git_tree *tree); + +/** + * Get the number of entries listed in a tree + * @param tree a previously loaded tree. + * @return the number of entries in the tree + */ +GIT_EXTERN(size_t) git_tree_entrycount(git_tree *tree); + +/** + * Lookup a tree entry by its filename + * @param tree a previously loaded tree. + * @param filename the filename of the desired entry + * @return the tree entry; NULL if not found + */ +GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(git_tree *tree, const char *filename); + +/** + * Lookup a tree entry by its position in the tree + * @param tree a previously loaded tree. + * @param idx the position in the entry list + * @return the tree entry; NULL if not found + */ +GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex(git_tree *tree, int idx); + +/** + * Get the UNIX file attributes of a tree entry + * @param entry a tree entry + * @return attributes as an integer + */ +GIT_EXTERN(uint32_t) git_tree_entry_attributes(const git_tree_entry *entry); + +/** + * Get the filename of a tree entry + * @param entry a tree entry + * @return the name of the file + */ +GIT_EXTERN(const char *) git_tree_entry_name(const git_tree_entry *entry); + +/** + * Get the id of the object pointed by the entry + * @param entry a tree entry + * @return the oid of the object + */ +GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry); + +/** + * Convert a tree entry to the git_repository_object it points too. + * @param entry a tree entry + * @return a reference to the pointed object in the repository + */ +GIT_EXTERN(git_repository_object *) git_tree_entry_2object(const git_tree_entry *entry); + /** @} */ GIT_END_DECL #endif |