Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 132 lines (109 sloc) 3.986 kb
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
1 #ifndef DIR_H
2 #define DIR_H
3
eb41775 @gitster ls-files -i: pay attention to exclusion of leading paths
gitster authored
4 #include "strbuf.h"
5
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
6 struct dir_entry {
e96980e @peff builtin-add: simplify (and increase accuracy of) exclude handling
peff authored
7 unsigned int len;
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
8 char name[FLEX_ARRAY]; /* more */
9 };
10
68492fc Speedup scanning for excluded files.
Lars Knoll authored
11 #define EXC_FLAG_NODIR 1
12 #define EXC_FLAG_ENDSWITH 4
d6b8fc3 @gitster gitignore(5): Allow "foo/" in ignore list to match directory "foo"
gitster authored
13 #define EXC_FLAG_MUSTBEDIR 8
68492fc Speedup scanning for excluded files.
Lars Knoll authored
14
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
15 struct exclude_list {
16 int nr;
17 int alloc;
18 struct exclude {
19 const char *pattern;
68492fc Speedup scanning for excluded files.
Lars Knoll authored
20 int patternlen;
f9f6e2c @pclouds exclude: do strcmp as much as possible before fnmatch
pclouds authored
21 int nowildcardlen;
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
22 const char *base;
23 int baselen;
68492fc Speedup scanning for excluded files.
Lars Knoll authored
24 int to_exclude;
25 int flags;
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
26 } **excludes;
27 };
28
63d285c @gitster per-directory-exclude: lazily read .gitignore files
gitster authored
29 struct exclude_stack {
30 struct exclude_stack *prev;
31 char *filebuf;
32 int baselen;
33 int exclude_ix;
34 };
35
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
36 struct dir_struct {
37 int nr, alloc;
2abd31b @peff dir_struct: add collect_ignored option
peff authored
38 int ignored_nr, ignored_alloc;
7c4c97c @dscho Turn the flags in struct dir_struct into a single variable
dscho authored
39 enum {
40 DIR_SHOW_IGNORED = 1<<0,
41 DIR_SHOW_OTHER_DIRECTORIES = 1<<1,
42 DIR_HIDE_EMPTY_DIRECTORIES = 1<<2,
43 DIR_NO_GITLINKS = 1<<3,
44 DIR_COLLECT_IGNORED = 1<<4
45 } flags;
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
46 struct dir_entry **entries;
2abd31b @peff dir_struct: add collect_ignored option
peff authored
47 struct dir_entry **ignored;
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
48
49 /* Exclude info */
50 const char *exclude_per_dir;
51 struct exclude_list exclude_list[3];
63d285c @gitster per-directory-exclude: lazily read .gitignore files
gitster authored
52 /*
53 * We maintain three exclude pattern lists:
54 * EXC_CMDL lists patterns explicitly given on the command line.
55 * EXC_DIRS lists patterns obtained from per-directory ignore files.
56 * EXC_FILE lists patterns from fallback ignore files.
57 */
58 #define EXC_CMDL 0
59 #define EXC_DIRS 1
60 #define EXC_FILE 2
61
62 struct exclude_stack *exclude_stack;
63 char basebuf[PATH_MAX];
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
64 };
65
e813d50 match_pathspec() -- return how well the spec matched
Junio C Hamano authored
66 #define MATCHED_RECURSIVELY 1
67 #define MATCHED_FNMATCH 2
68 #define MATCHED_EXACTLY 3
f950eb9 @drizzd rename pathspec_prefix() to common_prefix() and move to dir.[ch]
drizzd authored
69 extern char *common_prefix(const char **pathspec);
3c6a370 Move pathspec matching from builtin-add.c into dir.c
Linus Torvalds authored
70 extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen);
61cf282 @pclouds pathspec: add match_pathspec_depth()
pclouds authored
71 extern int match_pathspec_depth(const struct pathspec *pathspec,
72 const char *name, int namelen,
73 int prefix, char *seen);
bc96cc8 @pclouds tree_entry_interesting(): support depth limit
pclouds authored
74 extern int within_depth(const char *name, int namelen, int depth, int max_depth);
3c6a370 Move pathspec matching from builtin-add.c into dir.c
Linus Torvalds authored
75
1d8842d @torvalds Add 'fill_directory()' helper function for directory traversal
torvalds authored
76 extern int fill_directory(struct dir_struct *dir, const char **pathspec);
dba2e20 @torvalds Simplify read_directory[_recursive]() arguments
torvalds authored
77 extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec);
f8a9d42 read-tree: further loosen "working file will be lost" check.
Junio C Hamano authored
78
cb09753 @pclouds dir.c: export excluded_1() and add_excludes_from_file_1()
pclouds authored
79 extern int excluded_from_list(const char *pathname, int pathlen, const char *basename,
80 int *dtype, struct exclude_list *el);
108da0d @jlehmann git add: Add the "--ignore-missing" option for the dry run
jlehmann authored
81 struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len);
eb41775 @gitster ls-files -i: pay attention to exclusion of leading paths
gitster authored
82
83 /*
84 * The excluded() API is meant for callers that check each level of leading
85 * directory hierarchies with excluded() to avoid recursing into excluded
86 * directories. Callers that do not do so should use this API instead.
87 */
88 struct path_exclude_check {
89 struct dir_struct *dir;
90 struct strbuf path;
91 };
92 extern void path_exclude_check_init(struct path_exclude_check *, struct dir_struct *);
93 extern void path_exclude_check_clear(struct path_exclude_check *);
782cd4c @gitster path_excluded(): update API to less cache-entry centric
gitster authored
94 extern int path_excluded(struct path_exclude_check *, const char *, int namelen, int *dtype);
95
eb41775 @gitster ls-files -i: pay attention to exclusion of leading paths
gitster authored
96
cb09753 @pclouds dir.c: export excluded_1() and add_excludes_from_file_1()
pclouds authored
97 extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
98 char **buf_p, struct exclude_list *which, int check_index);
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
99 extern void add_excludes_from_file(struct dir_struct *, const char *fname);
100 extern void add_exclude(const char *string, const char *base,
101 int baselen, struct exclude_list *which);
0fd0e24 @pclouds dir.c: add free_excludes()
pclouds authored
102 extern void free_excludes(struct exclude_list *el);
c91f0d9 @peff git-commit.sh: convert run_status to a C builtin
peff authored
103 extern int file_exists(const char *);
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
104
e663674 @dscho Add functions get_relative_cwd() and is_inside_dir()
dscho authored
105 extern int is_inside_dir(const char *dir);
9b125da @pclouds setup: return correct prefix if worktree is '/'
pclouds authored
106 extern int dir_inside_of(const char *subdir, const char *dir);
e663674 @dscho Add functions get_relative_cwd() and is_inside_dir()
dscho authored
107
8ca12c0 @aspotashev add is_dot_or_dotdot inline function
aspotashev authored
108 static inline int is_dot_or_dotdot(const char *name)
109 {
110 return (name[0] == '.' &&
111 (name[1] == '\0' ||
112 (name[1] == '.' && name[2] == '\0')));
113 }
114
55892d2 @aspotashev Allow cloning to an existing empty directory
aspotashev authored
115 extern int is_empty_dir(const char *dir);
116
039bc64 @gitster core.excludesfile clean-up
gitster authored
117 extern void setup_standard_excludes(struct dir_struct *dir);
a0f4afb @gitster clean: require double -f options to nuke nested git repository and work ...
gitster authored
118
119 #define REMOVE_DIR_EMPTY_ONLY 01
120 #define REMOVE_DIR_KEEP_NESTED_GIT 02
c844a80 @gitster remove_dir_recursively(): Add flag for skipping removal of toplevel dir
gitster authored
121 #define REMOVE_DIR_KEEP_TOPLEVEL 04
a0f4afb @gitster clean: require double -f options to nuke nested git repository and work ...
gitster authored
122 extern int remove_dir_recursively(struct strbuf *path, int flag);
7155b72 @dscho Introduce remove_dir_recursively()
dscho authored
123
4a92d1b @raalkml Add remove_path: a function to remove as much as possible of a path
raalkml authored
124 /* tries to remove the path with empty directories along it, ignores ENOENT */
125 extern int remove_path(const char *path);
126
8cf2a84 @jjensen Add string comparison functions that respect the ignore_case variable.
jjensen authored
127 extern int strcmp_icase(const char *a, const char *b);
128 extern int strncmp_icase(const char *a, const char *b, size_t count);
129 extern int fnmatch_icase(const char *pattern, const char *string, int flags);
130
453ec4b libify git-ls-files directory traversal
Linus Torvalds authored
131 #endif
Something went wrong with that request. Please try again.