summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-03 00:28:32 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2015-02-04 14:15:13 +0000
commitf58cc280c9ddeff6fd85f56e70073c3ed4fb0650 (patch)
tree090d5f5de4c0dd4d8526dc48fa6d49d719fa55d5
parentd4b1b76701cb0495993b31b1b0e98c0a4b49c0ce (diff)
downloadlibgit2-f58cc280c9ddeff6fd85f56e70073c3ed4fb0650.tar.gz
attr_session: keep a temp buffer
-rw-r--r--src/attr_file.c1
-rw-r--r--src/attr_file.h1
-rw-r--r--src/attrcache.c10
3 files changed, 9 insertions, 3 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 2ebd3b91f..8997946b9 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -861,6 +861,7 @@ void git_attr_session__free(git_attr_session *session)
return;
git_buf_free(&session->sysdir);
+ git_buf_free(&session->tmp);
memset(session, 0, sizeof(git_attr_session));
}
diff --git a/src/attr_file.h b/src/attr_file.h
index 5c64f7cc3..aa9a16de0 100644
--- a/src/attr_file.h
+++ b/src/attr_file.h
@@ -114,6 +114,7 @@ typedef struct {
unsigned int init_setup:1,
init_sysdir:1;
git_buf sysdir;
+ git_buf tmp;
} git_attr_session;
extern int git_attr_session__init(git_attr_session *attr_session, git_repository *repo);
diff --git a/src/attrcache.c b/src/attrcache.c
index f75edad68..9a9b9d09d 100644
--- a/src/attrcache.c
+++ b/src/attrcache.c
@@ -149,6 +149,7 @@ 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)
@@ -162,9 +163,12 @@ static int attr_cache_lookup(
/* 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;
@@ -208,7 +212,7 @@ int git_attr_cache__get(
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 */