summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2011-10-13 14:54:12 -0700
committerVicent Martí <tanoku@gmail.com>2011-10-13 14:54:12 -0700
commitb7e1dd1603def3bce370d7d3fa03778999623033 (patch)
tree920698d515abc6a21adf3676b3694f52be80bb5a /include/git2
parent5c3d5fb0182e8c5307dedf9af281fe367a30a16e (diff)
parent3fa735ca3b8d8f855e43be44b5f96e59909d50e1 (diff)
downloadlibgit2-b7e1dd1603def3bce370d7d3fa03778999623033.tar.gz
Merge pull request #448 from nulltoken/ntk/topic/treeentry-random-access
Add git_tree_frompath()
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/oid.h10
-rw-r--r--include/git2/tree.h14
2 files changed, 24 insertions, 0 deletions
diff --git a/include/git2/oid.h b/include/git2/oid.h
index f9636d1fc..b9824b887 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -150,6 +150,16 @@ GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, unsigned int len);
/**
+ * Check if an oid equals an hex formatted object id.
+ *
+ * @param a oid structure.
+ * @param str input hex string of an object id.
+ * @return GIT_ENOTOID if str is not a valid hex string,
+ * GIT_SUCCESS in case of a match, GIT_ERROR otherwise.
+ */
+GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str);
+
+/**
* OID Shortener object
*/
typedef struct git_oid_shorten git_oid_shorten;
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