diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileops.h | 3 | ||||
| -rw-r--r-- | src/tree.c | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/fileops.h b/src/fileops.h index 4a86e1c63..c114508db 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -20,6 +20,9 @@ #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)) { diff --git a/src/tree.c b/src/tree.c index 60413e276..d539f83e2 100644 --- a/src/tree.c +++ b/src/tree.c @@ -100,6 +100,18 @@ const git_oid *git_tree_entry_id(const git_tree_entry *entry) 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); |
