*/
GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry);
+/**
+ * Get the type of the object pointed by the entry
+ *
+ * @param entry a tree entry
+ * @return the type of the pointed object
+ */
+GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
+
/**
* Convert a tree entry to the git_object it points too.
*
#define GIT_PLATFORM_PATH_SEP '/'
#endif
+#define S_IFGITLINK 0160000
+#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
+
#ifdef GIT_WIN32
GIT_INLINE(int) link(const char *GIT_UNUSED(old), const char *GIT_UNUSED(new))
{
return &entry->oid;
}
+git_otype git_tree_entry_type(const git_tree_entry *entry)
+{
+ assert(entry);
+
+ if (S_ISGITLINK(entry->attr))
+ return GIT_OBJ_COMMIT;
+ else if (S_ISDIR(entry->attr))
+ return GIT_OBJ_TREE;
+ else
+ return GIT_OBJ_BLOB;
+}
+
int git_tree_entry_2object(git_object **object_out, git_repository *repo, const git_tree_entry *entry)
{
assert(entry && object_out);