libgit2

git_ignore_add_rule

Version:

Add ignore rules for a repository.

Excludesfile rules (i.e. .gitignore rules) are generally read from .gitignore files in the repository tree or from a shared system file only if a "core.excludesfile" config value is set. The library also keeps a set of per-repository internal ignores that can be configured in-memory and will not persist. This function allows you to add to that internal rules list.

Example usage:

error = git_ignore_add_rule(myrepo, "*.c\ndir/\nFile with space\n");

This would add three rules to the ignores.

Signature

int git_ignore_add_rule(git_repository *repo, const char *rules);

Parameters

In
repo

The repository to add ignore rules to.

const char *
In
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.

Returns

int

0 on success

Versions