vendor/libgit2/src/attrcache.c in rugged-0.22.2 vs vendor/libgit2/src/attrcache.c in rugged-0.23.0b1

- old
+ new

@@ -3,11 +3,11 @@ #include "attr_file.h" #include "config.h" #include "sysdir.h" #include "ignore.h" -GIT__USE_STRMAP; +GIT__USE_STRMAP GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache) { GIT_UNUSED(cache); /* avoid warning if threading is off */ @@ -147,10 +147,11 @@ */ static int attr_cache_lookup( git_attr_file **out_file, git_attr_file_entry **out_entry, git_repository *repo, + git_attr_session *attr_session, git_attr_file_source source, const char *base, const char *filename) { int error = 0; @@ -160,13 +161,16 @@ git_attr_file_entry *entry = NULL; git_attr_file *file = NULL; /* join base and path as needed */ if (base != NULL && git_path_root(filename) < 0) { - if (git_buf_joinpath(&path, base, filename) < 0) + git_buf *p = attr_session ? &attr_session->tmp : &path; + + if (git_buf_joinpath(p, base, filename) < 0) return -1; - filename = path.ptr; + + filename = p->ptr; } relfile = filename; if (wd && !git__prefixcmp(relfile, wd)) relfile += strlen(wd); @@ -194,10 +198,11 @@ } int git_attr_cache__get( git_attr_file **out, git_repository *repo, + git_attr_session *attr_session, git_attr_file_source source, const char *base, const char *filename, git_attr_file_parser parser) { @@ -205,16 +210,16 @@ git_attr_cache *cache = git_repository_attr_cache(repo); git_attr_file_entry *entry = NULL; git_attr_file *file = NULL, *updated = NULL; if ((error = attr_cache_lookup( - &file, &entry, repo, source, base, filename)) < 0) + &file, &entry, repo, attr_session, source, base, filename)) < 0) return error; /* load file if we don't have one or if existing one is out of date */ - if (!file || (error = git_attr_file__out_of_date(repo, file)) > 0) - error = git_attr_file__load(&updated, repo, entry, source, parser); + if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0) + error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser); /* if we loaded the file, insert into and/or update cache */ if (updated) { if ((error = attr_cache_upsert(cache, updated)) < 0) git_attr_file__free(updated); @@ -269,11 +274,11 @@ static int attr_cache__lookup_path( char **out, git_config *cfg, const char *key, const char *fallback) { git_buf buf = GIT_BUF_INIT; int error; - const git_config_entry *entry = NULL; + git_config_entry *entry = NULL; *out = NULL; if ((error = git_config__lookup_entry(&entry, cfg, key, false)) < 0) return error; @@ -289,9 +294,10 @@ *out = git__strdup(cfgval); } else if (!git_sysdir_find_xdg_file(&buf, fallback)) *out = git_buf_detach(&buf); + git_config_entry_free(entry); git_buf_free(&buf); return error; }