]>
Commit | Line | Data |
---|---|---|
df743c7d | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
df743c7d RB |
3 | * |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with | |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
6 | */ | |
7 | #ifndef INCLUDE_ignore_h__ | |
8 | #define INCLUDE_ignore_h__ | |
9 | ||
eae0bfdc PP |
10 | #include "common.h" |
11 | ||
df743c7d RB |
12 | #include "repository.h" |
13 | #include "vector.h" | |
5540d947 RB |
14 | #include "attr_file.h" |
15 | ||
16 | #define GIT_IGNORE_FILE ".gitignore" | |
c5f3da96 | 17 | #define GIT_IGNORE_FILE_INREPO "exclude" |
5540d947 | 18 | #define GIT_IGNORE_FILE_XDG "ignore" |
df743c7d | 19 | |
b6c93aef RB |
20 | /* The git_ignores structure maintains three sets of ignores: |
21 | * - internal ignores | |
22 | * - per directory ignores | |
23 | * - global ignores (at lower priority than the others) | |
24 | * As you traverse from one directory to another, you can push and pop | |
25 | * directories onto git_ignores list efficiently. | |
26 | */ | |
adc9bdb3 RB |
27 | typedef struct { |
28 | git_repository *repo; | |
e579e0f7 | 29 | git_str dir; /* current directory reflected in ign_path */ |
b6c93aef RB |
30 | git_attr_file *ign_internal; |
31 | git_vector ign_path; | |
32 | git_vector ign_global; | |
6a0956e5 | 33 | size_t dir_root; /* offset in dir to repo root */ |
eac76c23 | 34 | int ignore_case; |
8f7bc646 | 35 | int depth; |
adc9bdb3 RB |
36 | } git_ignores; |
37 | ||
ba8b8c04 RB |
38 | extern int git_ignore__for_path( |
39 | git_repository *repo, const char *path, git_ignores *ign); | |
b6c93aef RB |
40 | |
41 | extern int git_ignore__push_dir(git_ignores *ign, const char *dir); | |
f917481e | 42 | |
b6c93aef RB |
43 | extern int git_ignore__pop_dir(git_ignores *ign); |
44 | ||
45 | extern void git_ignore__free(git_ignores *ign); | |
f917481e | 46 | |
f554611a RB |
47 | enum { |
48 | GIT_IGNORE_UNCHECKED = -2, | |
49 | GIT_IGNORE_NOTFOUND = -1, | |
50 | GIT_IGNORE_FALSE = 0, | |
e579e0f7 | 51 | GIT_IGNORE_TRUE = 1 |
f554611a RB |
52 | }; |
53 | ||
4c09e19a | 54 | extern int git_ignore__lookup(int *out, git_ignores *ign, const char *path, git_dir_flag dir_flag); |
df743c7d | 55 | |
85b8b18b RB |
56 | /* command line Git sometimes generates an error message if given a |
57 | * pathspec that contains an exact match to an ignored file (provided | |
58 | * --force isn't also given). This makes it easy to check it that has | |
59 | * happened. Returns GIT_EINVALIDSPEC if the pathspec contains ignored | |
60 | * exact matches (that are not already present in the index). | |
61 | */ | |
62 | extern int git_ignore__check_pathspec_for_exact_ignores( | |
63 | git_repository *repo, git_vector *pathspec, bool no_fnmatch); | |
64 | ||
df743c7d | 65 | #endif |