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 /**
8  * License: GPL-2.0(Linking Exception)
9  */
10 module libgit2.ignore;
11 
12 
13 private static import libgit2.types;
14 private import libgit2.common: GIT_EXTERN;
15 
16 extern (C):
17 nothrow @nogc:
18 public:
19 
20 /**
21  * Add ignore rules for a repository.
22  *
23  * Excludesfile rules (i.e. .gitignore rules) are generally read from
24  * .gitignore files in the repository tree or from a shared system file
25  * only if a "core.excludesfile" config value is set.  The library also
26  * keeps a set of per-repository internal ignores that can be configured
27  * in-memory and will not persist.  This function allows you to add to
28  * that internal rules list.
29  *
30  * Example usage:
31  *
32  *     error = git_ignore_add_rule(myrepo, "*.c\ndir/\nFile with space\n");
33  *
34  * This would add three rules to the ignores.
35  *
36  * Params:
37  *      repo = The repository to add ignore rules to.
38  *      rules = Text of rules, the contents to add on a .gitignore file. It is okay to have multiple rules in the text; if so, each rule should be terminated with a newline.
39  *
40  * Returns: 0 on success
41  */
42 @GIT_EXTERN
43 int git_ignore_add_rule(libgit2.types.git_repository* repo, const (char)* rules);
44 
45 /**
46  * Clear ignore rules that were explicitly added.
47  *
48  * Resets to the default internal ignore rules.  This will not turn off
49  * rules in .gitignore files that actually exist in the filesystem.
50  *
51  * The default internal ignores ignore ".", ".." and ".git" entries.
52  *
53  * Params:
54  *      repo = The repository to remove ignore rules from.
55  *
56  * Returns: 0 on success
57  */
58 @GIT_EXTERN
59 int git_ignore_clear_internal_rules(libgit2.types.git_repository* repo);
60 
61 /**
62  * Test if the ignore rules apply to a given path.
63  *
64  * This function checks the ignore rules to see if they would apply to the
65  * given file.  This indicates if the file would be ignored regardless of
66  * whether the file is already in the index or committed to the repository.
67  *
68  * One way to think of this is if you were to do "git check-ignore --no-index"
69  * on the given file, would it be shown or not?
70  *
71  * Params:
72  *      ignored = boolean returning 0 if the file is not ignored, 1 if it is
73  *      repo = a repository object
74  *      path = the file to check ignores for, relative to the repo's workdir.
75  *
76  * Returns: 0 if ignore rules could be processed for the file (regardless of whether it exists or not), or an error < 0 if they could not.
77  */
78 @GIT_EXTERN
79 int git_ignore_path_is_ignored(int* ignored, libgit2.types.git_repository* repo, const (char)* path);