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