dir.c: minor clean-up
[git/git.git] / dir.h
CommitLineData
453ec4bd
LT
1#ifndef DIR_H
2#define DIR_H
3
4/*
5 * We maintain three exclude pattern lists:
6 * EXC_CMDL lists patterns explicitly given on the command line.
7 * EXC_DIRS lists patterns obtained from per-directory ignore files.
8 * EXC_FILE lists patterns from fallback ignore files.
9 */
10#define EXC_CMDL 0
11#define EXC_DIRS 1
12#define EXC_FILE 2
13
14
15struct dir_entry {
e96980ef 16 unsigned int len;
453ec4bd
LT
17 char name[FLEX_ARRAY]; /* more */
18};
19
68492fc7
LK
20#define EXC_FLAG_NODIR 1
21#define EXC_FLAG_NOWILDCARD 2
22#define EXC_FLAG_ENDSWITH 4
23
453ec4bd
LT
24struct exclude_list {
25 int nr;
26 int alloc;
27 struct exclude {
28 const char *pattern;
68492fc7 29 int patternlen;
453ec4bd
LT
30 const char *base;
31 int baselen;
68492fc7
LK
32 int to_exclude;
33 int flags;
453ec4bd
LT
34 } **excludes;
35};
36
37struct dir_struct {
38 int nr, alloc;
2abd31b0 39 int ignored_nr, ignored_alloc;
c889763b 40 unsigned int show_ignored:1,
453ec4bd 41 show_other_directories:1,
09595258 42 hide_empty_directories:1,
2abd31b0
JK
43 no_gitlinks:1,
44 collect_ignored:1;
453ec4bd 45 struct dir_entry **entries;
2abd31b0 46 struct dir_entry **ignored;
453ec4bd
LT
47
48 /* Exclude info */
49 const char *exclude_per_dir;
50 struct exclude_list exclude_list[3];
51};
52
3c6a370b 53extern int common_prefix(const char **pathspec);
e813d50e
JH
54
55#define MATCHED_RECURSIVELY 1
56#define MATCHED_FNMATCH 2
57#define MATCHED_EXACTLY 3
3c6a370b
LT
58extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen);
59
9fc42d60 60extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen, const char **pathspec);
f8a9d428
JH
61extern int push_exclude_per_directory(struct dir_struct *, const char *, int);
62extern void pop_exclude_per_directory(struct dir_struct *, int);
63
453ec4bd
LT
64extern int excluded(struct dir_struct *, const char *);
65extern void add_excludes_from_file(struct dir_struct *, const char *fname);
66extern void add_exclude(const char *string, const char *base,
67 int baselen, struct exclude_list *which);
c91f0d92 68extern int file_exists(const char *);
4d06f8ac 69extern struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len);
453ec4bd 70
e6636747
JS
71extern char *get_relative_cwd(char *buffer, int size, const char *dir);
72extern int is_inside_dir(const char *dir);
73
039bc64e 74extern void setup_standard_excludes(struct dir_struct *dir);
7155b727
JS
75extern int remove_dir_recursively(struct strbuf *path, int only_empty);
76
453ec4bd 77#endif