summaryrefslogtreecommitdiff
path: root/src/ignore.h
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-02-21 14:46:24 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-02-21 14:46:24 -0800
commitb6c93aef4276051f9c4536ecbed48f4cd093bd1b (patch)
treea15962c672890c0c8cc021dafa7d29487f81c75a /src/ignore.h
parent9c94a356cc61daa85e17c6342db9b3d62f788802 (diff)
downloadlibgit2-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/ignore.h')
-rw-r--r--src/ignore.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/ignore.h b/src/ignore.h
index 386322ff2..49f72bf25 100644
--- a/src/ignore.h
+++ b/src/ignore.h
@@ -10,14 +10,28 @@
#include "repository.h"
#include "vector.h"
+/* The git_ignores structure maintains three sets of ignores:
+ * - internal ignores
+ * - per directory ignores
+ * - global ignores (at lower priority than the others)
+ * As you traverse from one directory to another, you can push and pop
+ * directories onto git_ignores list efficiently.
+ */
typedef struct {
git_repository *repo;
- char *dir;
- git_vector stack;
+ git_buf dir;
+ git_attr_file *ign_internal;
+ git_vector ign_path;
+ git_vector ign_global;
} git_ignores;
-extern int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *stack);
-extern void git_ignore__free(git_ignores *stack);
-extern int git_ignore__lookup(git_ignores *stack, const char *path, int *ignored);
+extern int git_ignore__for_path(
+ git_repository *repo, const char *path, git_ignores *ign);
+
+extern int git_ignore__push_dir(git_ignores *ign, const char *dir);
+extern int git_ignore__pop_dir(git_ignores *ign);
+
+extern void git_ignore__free(git_ignores *ign);
+extern int git_ignore__lookup(git_ignores *ign, const char *path, int *ignored);
#endif