summaryrefslogtreecommitdiff
path: root/src/attr_file.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-05-03 16:37:25 -0700
committerRussell Belfer <rb@github.com>2012-05-03 16:37:25 -0700
commitf917481ee84cbba481c1854cccdedb2d98377d43 (patch)
treeb6276158b43f8d54358df5609fd0e508928306b2 /src/attr_file.h
parent3fbcac89c47cb66ea193f66da6d93d1c36ed0f5e (diff)
downloadlibgit2-f917481ee84cbba481c1854cccdedb2d98377d43.tar.gz
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.
Diffstat (limited to 'src/attr_file.h')
-rw-r--r--src/attr_file.h21
1 files changed, 13 insertions, 8 deletions
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 <rule*> or <fnmatch*> */
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,