aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-16 17:57:06 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-16 17:57:06 -0800
commit987e315a6b5a5dd224602f09b9dc7c0fe9c7d024 (patch)
treece10af22609413c4316e12335387bcfa0ef1bf9b /cache.h
parent1ae419cb3902e6cc45538a9673539ed5316fcf30 (diff)
parent6831a88ac03759a8133f10ffd52ad235a081a8a3 (diff)
downloadgit-987e315a6b5a5dd224602f09b9dc7c0fe9c7d024.tar.gz
git-987e315a6b5a5dd224602f09b9dc7c0fe9c7d024.tar.xz
Merge branch 'jc/gitignore-ends-with-slash'
* jc/gitignore-ends-with-slash: gitignore: lazily find dtype gitignore(5): Allow "foo/" in ignore list to match directory "foo"
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index efd31d856..18fe8447f 100644
--- a/cache.h
+++ b/cache.h
@@ -178,6 +178,18 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
}
return create_ce_mode(mode);
}
+static inline int ce_to_dtype(const struct cache_entry *ce)
+{
+ unsigned ce_mode = ntohl(ce->ce_mode);
+ if (S_ISREG(ce_mode))
+ return DT_REG;
+ else if (S_ISDIR(ce_mode) || S_ISGITLINK(ce_mode))
+ return DT_DIR;
+ else if (S_ISLNK(ce_mode))
+ return DT_LNK;
+ else
+ return DT_UNKNOWN;
+}
#define canon_mode(mode) \
(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFGITLINK)