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 * Params: 33 * repo = The repository to add ignore rules to. 34 * rules = Text of rules, a la the contents of a .gitignore file. It is okay to have multiple rules in the text; if so, each rule should be terminated with a newline. 35 * 36 * Returns: 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 * Params: 50 * repo = The repository to remove ignore rules from. 51 * 52 * Returns: 0 on success 53 */ 54 //GIT_EXTERN 55 int git_ignore_clear_internal_rules(libgit2_d.types.git_repository* repo); 56 57 /** 58 * Test if the ignore rules apply to a given path. 59 * 60 * This function checks the ignore rules to see if they would apply to the 61 * given file. This indicates if the file would be ignored regardless of 62 * whether the file is already in the index or committed to the repository. 63 * 64 * One way to think of this is if you were to do "git check-ignore --no-index" 65 * on the given file, would it be shown or not? 66 * 67 * Params: 68 * ignored = boolean returning 0 if the file is not ignored, 1 if it is 69 * repo = a repository object 70 * path = the file to check ignores for, relative to the repo's workdir. 71 * 72 * 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. 73 */ 74 //GIT_EXTERN 75 int git_ignore_path_is_ignored(int* ignored, libgit2_d.types.git_repository* repo, const (char)* path);