From 3fa735ca3b8d8f855e43be44b5f96e59909d50e1 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 13 Oct 2011 23:17:19 +0200 Subject: tree: Add git_tree_frompath() which, given a relative path to a tree entry, retrieves the tree object containing this tree entry --- include/git2/tree.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/git2') diff --git a/include/git2/tree.h b/include/git2/tree.h index d781ea136..8d638f723 100644 --- a/include/git2/tree.h +++ b/include/git2/tree.h @@ -268,6 +268,20 @@ GIT_EXTERN(void) git_treebuilder_filter(git_treebuilder *bld, int (*filter)(cons */ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld); +/** + * Retrieve the tree object containing a tree entry, given + * a relative path to this tree entry + * + * The returned tree is owned by the repository and + * should be closed with the `git_object_close` method. + * + * @param parent_out Pointer where to store the parent tree + * @param root A previously loaded tree which will be the root of the relative path + * @param treeentry_path Path to the tree entry from which to extract the last tree object + * @return GIT_SUCCESS on success; GIT_ENOTFOUND if the path does not lead to an + * entry, GIT_EINVALIDPATH or an error code + */ +GIT_EXTERN(int) git_tree_frompath(git_tree **parent_out, git_tree *root, const char *treeentry_path); /** @} */ GIT_END_DECL #endif -- cgit v1.2.1