diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-02-21 14:46:24 -0800 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-02-21 14:46:24 -0800 |
| commit | b6c93aef4276051f9c4536ecbed48f4cd093bd1b (patch) | |
| tree | a15962c672890c0c8cc021dafa7d29487f81c75a /src/fileops.c | |
| parent | 9c94a356cc61daa85e17c6342db9b3d62f788802 (diff) | |
| download | libgit2-b6c93aef4276051f9c4536ecbed48f4cd093bd1b.tar.gz | |
Uniform iterators for trees, index, and workdir
This create a new git_iterator type of object that provides a
uniform interface for iterating over the index, an arbitrary
tree, or the working directory of a repository.
As part of this, git ignore support was extended to support
push and pop of directory-based ignore files as the working
directory is being traversed (so the array of ignores does
not have to be recreated at each directory during traveral).
There are a number of other small utility functions in buffer,
path, vector, and fileops that are included in this patch
that made the iterator implementation cleaner.
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/fileops.c b/src/fileops.c index cea954def..3241c68b1 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -79,6 +79,24 @@ git_off_t git_futils_filesize(git_file fd) return sb.st_size; } +#define GIT_MODE_PERMS_MASK 0777 +#define GIT_CANONICAL_PERMS(MODE) (((MODE) & 0100) ? 0755 : 0644) +#define GIT_MODE_TYPE(MODE) ((MODE) & ~GIT_MODE_PERMS_MASK) + +mode_t git_futils_canonical_mode(mode_t raw_mode) +{ + if (S_ISREG(raw_mode)) + return S_IFREG | GIT_CANONICAL_PERMS(raw_mode); + else if (S_ISLNK(raw_mode)) + return S_IFLNK; + else if (S_ISDIR(raw_mode)) + return S_IFDIR; + else if (S_ISGITLINK(raw_mode)) + return S_IFGITLINK; + else + return 0; +} + int git_futils_readbuffer_updated(git_fbuffer *obj, const char *path, time_t *mtime, int *updated) { git_file fd; |
