From f917481ee84cbba481c1854cccdedb2d98377d43 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 3 May 2012 16:37:25 -0700 Subject: Support reading attributes from index Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files. --- src/attr_file.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/attr_file.h') diff --git a/src/attr_file.h b/src/attr_file.h index 10851bc49..ec488c4dc 100644 --- a/src/attr_file.h +++ b/src/attr_file.h @@ -48,7 +48,7 @@ typedef struct { } git_attr_assignment; typedef struct { - char *path; /* cache the path this was loaded from */ + char *key; /* cache "source#path" this was loaded from */ git_vector rules; /* vector of or */ git_pool *pool; bool pool_is_allocated; @@ -61,20 +61,25 @@ typedef struct { int is_dir; } git_attr_path; +typedef enum { + GIT_ATTR_FILE_FROM_FILE = 0, + GIT_ATTR_FILE_FROM_INDEX = 1 +} git_attr_file_source; + /* * git_attr_file API */ -extern int git_attr_file__new(git_attr_file **attrs_ptr, git_pool *pool); +extern int git_attr_file__new( + git_attr_file **attrs_ptr, git_attr_file_source src, const char *path, git_pool *pool); + +extern int git_attr_file__new_and_load( + git_attr_file **attrs_ptr, const char *path); + extern void git_attr_file__free(git_attr_file *file); -extern int git_attr_file__from_buffer( +extern int git_attr_file__parse_buffer( git_repository *repo, const char *buf, git_attr_file *file); -extern int git_attr_file__from_file( - git_repository *repo, const char *path, git_attr_file *file); - -extern int git_attr_file__set_path( - git_repository *repo, const char *path, git_attr_file *file); extern int git_attr_file__lookup_one( git_attr_file *file, -- cgit v1.2.1