diff options
author | Russell Belfer <rb@github.com> | 2014-04-11 12:12:47 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-04-17 14:56:41 -0700 |
commit | 2e9d813bd69ab014b970a75b5a4f7d24f241cc05 (patch) | |
tree | 1a69b430eeb000dde22cd185571c79cb818f842d /src/attr.c | |
parent | 7d4908724fd7d4d8e096b4faf2c652ba5b77644e (diff) | |
download | libgit2-2e9d813bd69ab014b970a75b5a4f7d24f241cc05.tar.gz |
Fix tests with new attr cache code
Diffstat (limited to 'src/attr.c')
-rw-r--r-- | src/attr.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/attr.c b/src/attr.c index c53a728de..2e314998f 100644 --- a/src/attr.c +++ b/src/attr.c @@ -60,6 +60,7 @@ int git_attr_get( if ((error = collect_attr_files(repo, flags, pathname, &files)) < 0) goto cleanup; + memset(&attr, 0, sizeof(attr)); attr.name = name; attr.name_hash = git_attr_file__name_hash(name); @@ -295,11 +296,15 @@ static int push_attr_file( int error = 0; git_attr_file *file = NULL; - if ((error = git_attr_cache__get( - &file, repo, source, base, filename, - git_attr_file__parse_buffer, NULL)) < 0 || - (error = git_vector_insert(list, file)) < 0) - git_attr_file__free(file); + error = git_attr_cache__get( + &file, repo, source, base, filename, git_attr_file__parse_buffer, NULL); + if (error < 0) + return error; + + if (file != NULL) { + if ((error = git_vector_insert(list, file)) < 0) + git_attr_file__free(file); + } return error; } @@ -343,9 +348,8 @@ static int collect_attr_files( const char *workdir = git_repository_workdir(repo); attr_walk_up_info info = { NULL }; - if (git_attr_cache__init(repo) < 0 || - git_vector_init(files, 4, NULL) < 0) - return -1; + if ((error = git_attr_cache__init(repo)) < 0) + return error; /* Resolve path in a non-bare repo */ if (workdir != NULL) |