dir.hon commit Add tests for git push'es mirror mode (8e806ad)
   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 {
  16        unsigned int len;
  17        char name[FLEX_ARRAY]; /* more */
  18};
  19
  20#define EXC_FLAG_NODIR 1
  21#define EXC_FLAG_NOWILDCARD 2
  22#define EXC_FLAG_ENDSWITH 4
  23
  24struct exclude_list {
  25        int nr;
  26        int alloc;
  27        struct exclude {
  28                const char *pattern;
  29                int patternlen;
  30                const char *base;
  31                int baselen;
  32                int to_exclude;
  33                int flags;
  34        } **excludes;
  35};
  36
  37struct dir_struct {
  38        int nr, alloc;
  39        int ignored_nr, ignored_alloc;
  40        unsigned int show_ignored:1,
  41                     show_other_directories:1,
  42                     hide_empty_directories:1,
  43                     no_gitlinks:1,
  44                     collect_ignored:1;
  45        struct dir_entry **entries;
  46        struct dir_entry **ignored;
  47
  48        /* Exclude info */
  49        const char *exclude_per_dir;
  50        struct exclude_list exclude_list[3];
  51};
  52
  53extern int common_prefix(const char **pathspec);
  54
  55#define MATCHED_RECURSIVELY 1
  56#define MATCHED_FNMATCH 2
  57#define MATCHED_EXACTLY 3
  58extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen);
  59
  60extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen, const char **pathspec);
  61extern int push_exclude_per_directory(struct dir_struct *, const char *, int);
  62extern void pop_exclude_per_directory(struct dir_struct *, int);
  63
  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);
  68extern int file_exists(const char *);
  69extern struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len);
  70
  71extern char *get_relative_cwd(char *buffer, int size, const char *dir);
  72extern int is_inside_dir(const char *dir);
  73
  74extern int remove_dir_recursively(struct strbuf *path, int only_empty);
  75
  76#endif