mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 17:20:22 +00:00
Add public API for internal ignores
This creates a public API for adding to the internal ignores list, which already existing but was not accessible. This adds the new default value for core.excludesfile also.
This commit is contained in:
parent
b2be351aad
commit
f004c4a8a7
@ -41,6 +41,7 @@
|
|||||||
#include "git2/checkout.h"
|
#include "git2/checkout.h"
|
||||||
|
|
||||||
#include "git2/attr.h"
|
#include "git2/attr.h"
|
||||||
|
#include "git2/ignore.h"
|
||||||
#include "git2/branch.h"
|
#include "git2/branch.h"
|
||||||
#include "git2/refspec.h"
|
#include "git2/refspec.h"
|
||||||
#include "git2/net.h"
|
#include "git2/net.h"
|
||||||
|
10
src/attr.c
10
src/attr.c
@ -612,6 +612,16 @@ int git_attr_cache__init(git_repository *repo)
|
|||||||
if (ret < 0 && ret != GIT_ENOTFOUND)
|
if (ret < 0 && ret != GIT_ENOTFOUND)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (ret == GIT_ENOTFOUND) {
|
||||||
|
git_buf dflt = GIT_BUF_INIT;
|
||||||
|
|
||||||
|
ret = git_futils_find_global_file(&dflt, GIT_IGNORE_CONFIG_DEFAULT);
|
||||||
|
if (!ret)
|
||||||
|
cache->cfg_excl_file = git_buf_detach(&dflt);
|
||||||
|
|
||||||
|
git_buf_free(&dflt);
|
||||||
|
}
|
||||||
|
|
||||||
giterr_clear();
|
giterr_clear();
|
||||||
|
|
||||||
/* allocate hashtable for attribute and ignore file contents */
|
/* allocate hashtable for attribute and ignore file contents */
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#define GIT_ATTR_CONFIG "core.attributesfile"
|
#define GIT_ATTR_CONFIG "core.attributesfile"
|
||||||
#define GIT_IGNORE_CONFIG "core.excludesfile"
|
#define GIT_IGNORE_CONFIG "core.excludesfile"
|
||||||
|
#define GIT_IGNORE_CONFIG_DEFAULT ".config/git/ignore"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int initialized;
|
int initialized;
|
||||||
|
32
src/ignore.c
32
src/ignore.c
@ -1,3 +1,4 @@
|
|||||||
|
#include "git2/ignore.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
@ -203,3 +204,34 @@ cleanup:
|
|||||||
git_attr_path__free(&path);
|
git_attr_path__free(&path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_ignore_add_rule(
|
||||||
|
git_repository *repo,
|
||||||
|
const char *rules)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
git_attr_file *ign_internal;
|
||||||
|
|
||||||
|
error = git_attr_cache__internal_file(
|
||||||
|
repo, GIT_IGNORE_INTERNAL, &ign_internal);
|
||||||
|
|
||||||
|
if (!error && ign_internal != NULL)
|
||||||
|
error = parse_ignore_file(repo, rules, ign_internal);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int git_ignore_clear_internal_rules(
|
||||||
|
git_repository *repo)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
git_attr_file *ign_internal;
|
||||||
|
|
||||||
|
error = git_attr_cache__internal_file(
|
||||||
|
repo, GIT_IGNORE_INTERNAL, &ign_internal);
|
||||||
|
|
||||||
|
if (!error && ign_internal != NULL)
|
||||||
|
git_attr_file__clear_rules(ign_internal);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user