diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-01-29 14:40:55 -0600 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-02-03 00:31:08 -0500 |
commit | 9f779aacdd950fd53a407da615ca60d628e31d35 (patch) | |
tree | 55819aa11a18e2d272d75118239d23243b49357a /src/attr_file.h | |
parent | 60561d54468d7097e04466fd8125be5231cea637 (diff) | |
download | libgit2-9f779aacdd950fd53a407da615ca60d628e31d35.tar.gz |
attrcache: don't re-read attrs during checkout
During checkout, assume that the .gitattributes files aren't
modified during the checkout. Instead, create an "attribute session"
during checkout. Assume that attribute data read in the same
checkout "session" hasn't been modified since the checkout started.
(But allow subsequent checkouts to invalidate the cache.)
Further, cache nonexistent git_attr_file data even when .gitattributes
files are not found to prevent re-scanning for nonexistent files.
Diffstat (limited to 'src/attr_file.h')
-rw-r--r-- | src/attr_file.h | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/attr_file.h b/src/attr_file.h index 93de84d12..b8e37256b 100644 --- a/src/attr_file.h +++ b/src/attr_file.h @@ -38,11 +38,11 @@ GIT_ATTR_FNMATCH_ALLOWMACRO | GIT_ATTR_FNMATCH_NOLEADINGDIR) typedef enum { - GIT_ATTR_FILE__IN_MEMORY = 0, - GIT_ATTR_FILE__FROM_FILE = 1, - GIT_ATTR_FILE__FROM_INDEX = 2, + GIT_ATTR_FILE__IN_MEMORY = 0, + GIT_ATTR_FILE__FROM_FILE = 1, + GIT_ATTR_FILE__FROM_INDEX = 2, - GIT_ATTR_FILE_NUM_SOURCES = 3 + GIT_ATTR_FILE_NUM_SOURCES = 3 } git_attr_file_source; extern const char *git_attr__true; @@ -84,6 +84,8 @@ typedef struct { git_attr_file_source source; git_vector rules; /* vector of <rule*> or <fnmatch*> */ git_pool pool; + unsigned int nonexistent:1; + int session_key; union { git_oid oid; git_futils_filestamp stamp; @@ -96,11 +98,6 @@ struct git_attr_file_entry { char fullpath[GIT_FLEX_ARRAY]; }; -typedef int (*git_attr_file_parser)( - git_repository *repo, - git_attr_file *file, - const char *data); - typedef struct { git_buf full; char *path; @@ -108,6 +105,32 @@ typedef struct { int is_dir; } git_attr_path; +/* A git_attr_session can provide an "instance" of reading, to prevent cache + * invalidation during a single operation instance (like checkout). + */ + +typedef struct { + int key; + unsigned int setup; +} git_attr_session; + +extern int git_attr_session__init(git_attr_session *attr_session, git_repository *repo); +extern void git_attr_session__free(git_attr_session *session); + +extern int git_attr_get_many_with_session( + const char **values_out, + git_repository *repo, + git_attr_session *attr_session, + uint32_t flags, + const char *path, + size_t num_attr, + const char **names); + +typedef int (*git_attr_file_parser)( + git_repository *repo, + git_attr_file *file, + const char *data); + /* * git_attr_file API */ @@ -122,6 +145,7 @@ void git_attr_file__free(git_attr_file *file); int git_attr_file__load( git_attr_file **out, git_repository *repo, + git_attr_session *attr_session, git_attr_file_entry *ce, git_attr_file_source source, git_attr_file_parser parser); @@ -130,7 +154,7 @@ int git_attr_file__load_standalone( git_attr_file **out, const char *path); int git_attr_file__out_of_date( - git_repository *repo, git_attr_file *file); + git_repository *repo, git_attr_session *session, git_attr_file *file); int git_attr_file__parse_buffer( git_repository *repo, git_attr_file *attrs, const char *data); |