summaryrefslogtreecommitdiff
path: root/src/ignore.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-11 12:12:47 -0700
committerRussell Belfer <rb@github.com>2014-04-17 14:56:41 -0700
commit2e9d813bd69ab014b970a75b5a4f7d24f241cc05 (patch)
tree1a69b430eeb000dde22cd185571c79cb818f842d /src/ignore.c
parent7d4908724fd7d4d8e096b4faf2c652ba5b77644e (diff)
downloadlibgit2-2e9d813bd69ab014b970a75b5a4f7d24f241cc05.tar.gz
Fix tests with new attr cache code
Diffstat (limited to 'src/ignore.c')
-rw-r--r--src/ignore.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ignore.c b/src/ignore.c
index 3ee7ba03a..1f9df8ab4 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -77,11 +77,16 @@ static int push_ignore_file(
int error = 0;
git_attr_file *file = NULL;
- if ((error = git_attr_cache__get(
- &file, ignores->repo, GIT_ATTR_CACHE__FROM_FILE,
- base, filename, parse_ignore_file, ignores)) < 0 ||
- (error = git_vector_insert(which_list, file)) < 0)
- git_attr_file__free(file);
+ error = git_attr_cache__get(
+ &file, ignores->repo, GIT_ATTR_CACHE__FROM_FILE,
+ base, filename, parse_ignore_file, ignores);
+ if (error < 0)
+ return error;
+
+ if (file != NULL) {
+ if ((error = git_vector_insert(which_list, file)) < 0)
+ git_attr_file__free(file);
+ }
return error;
}
@@ -122,19 +127,15 @@ int git_ignore__for_path(
assert(ignores);
+ memset(ignores, 0, sizeof(*ignores));
ignores->repo = repo;
- git_buf_init(&ignores->dir, 0);
- ignores->ign_internal = NULL;
- ignores->depth = 0;
/* Read the ignore_case flag */
if ((error = git_repository__cvar(
&ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0)
goto cleanup;
- if ((error = git_vector_init(&ignores->ign_path, 8, NULL)) < 0 ||
- (error = git_vector_init(&ignores->ign_global, 2, NULL)) < 0 ||
- (error = git_attr_cache__init(repo)) < 0)
+ if ((error = git_attr_cache__init(repo)) < 0)
goto cleanup;
/* given a unrooted path in a non-bare repo, resolve it */
@@ -304,7 +305,7 @@ int git_ignore_add_rule(
git_attr_file *ign_internal = NULL;
if (!(error = get_internal_ignores(&ign_internal, repo))) {
- error = parse_ignore_file(repo, NULL, rules, ign_internal);
+ error = parse_ignore_file(repo, ign_internal, rules, NULL);
git_attr_file__free(ign_internal);
}
@@ -321,7 +322,7 @@ int git_ignore_clear_internal_rules(
git_attr_file__clear_rules(ign_internal);
error = parse_ignore_file(
- repo, NULL, GIT_IGNORE_DEFAULT_RULES, ign_internal);
+ repo, ign_internal, GIT_IGNORE_DEFAULT_RULES, NULL);
git_attr_file__free(ign_internal);
}