]> git.proxmox.com Git - libgit2.git/blob - src/ignore.h
patch: use strlen to mean string length
[libgit2.git] / src / ignore.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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
10 #include "repository.h"
11 #include "vector.h"
12 #include "attr_file.h"
13
14 #define GIT_IGNORE_FILE ".gitignore"
15 #define GIT_IGNORE_FILE_INREPO "info/exclude"
16 #define GIT_IGNORE_FILE_XDG "ignore"
17
18 /* The git_ignores structure maintains three sets of ignores:
19 * - internal ignores
20 * - per directory ignores
21 * - global ignores (at lower priority than the others)
22 * As you traverse from one directory to another, you can push and pop
23 * directories onto git_ignores list efficiently.
24 */
25 typedef struct {
26 git_repository *repo;
27 git_buf dir; /* current directory reflected in ign_path */
28 git_attr_file *ign_internal;
29 git_vector ign_path;
30 git_vector ign_global;
31 size_t dir_root; /* offset in dir to repo root */
32 int ignore_case;
33 int depth;
34 } git_ignores;
35
36 extern int git_ignore__for_path(
37 git_repository *repo, const char *path, git_ignores *ign);
38
39 extern int git_ignore__push_dir(git_ignores *ign, const char *dir);
40
41 extern int git_ignore__pop_dir(git_ignores *ign);
42
43 extern void git_ignore__free(git_ignores *ign);
44
45 enum {
46 GIT_IGNORE_UNCHECKED = -2,
47 GIT_IGNORE_NOTFOUND = -1,
48 GIT_IGNORE_FALSE = 0,
49 GIT_IGNORE_TRUE = 1,
50 };
51
52 extern int git_ignore__lookup(int *out, git_ignores *ign, const char *path, git_dir_flag dir_flag);
53
54 /* command line Git sometimes generates an error message if given a
55 * pathspec that contains an exact match to an ignored file (provided
56 * --force isn't also given). This makes it easy to check it that has
57 * happened. Returns GIT_EINVALIDSPEC if the pathspec contains ignored
58 * exact matches (that are not already present in the index).
59 */
60 extern int git_ignore__check_pathspec_for_exact_ignores(
61 git_repository *repo, git_vector *pathspec, bool no_fnmatch);
62
63 #endif