path: root/attr.h
diff options
authorNguyễn Thái Ngọc Duy <>2018-08-13 16:14:20 (GMT)
committerJunio C Hamano <>2018-08-13 21:14:42 (GMT)
commit7a400a2c0270f2085b70690e4ddbfd8d141e69ca (patch)
tree4629e63313178eb48ffce09d61f1e5adf7bbebd5 /attr.h
parent07096c969678a999c24816805d72bf7e0e840384 (diff)
attr: remove an implicit dependency on the_index
Make the attr API take an index_state instead of assuming the_index in attr code. All call sites are converted blindly to keep the patch simple and retain current behavior. Individual call sites may receive further updates to use the right index instead of the_index. There is one ugly temporary workaround added in attr.c that needs some more explanation. Commit c24f3abace (apply: file commited with CRLF should roundtrip diff and apply - 2017-08-19) forces one convert_to_git() call to NOT read the index at all. But what do you know, we read it anyway by falling back to the_index. When "istate" from convert_to_git is now propagated down to read_attr_from_array() we will hit segfault somewhere inside read_blob_data_from_index. The right way of dealing with this is to kill "use_index" variable and only follow "istate" but at this stage we are not ready for that: while most git_attr_set_direction() calls just passes the_index to be assigned to use_index, unpack-trees passes a different one which is used by entry.c code, which has no way to know what index to use if we delete use_index. So this has to be done later. Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'attr.h')
1 files changed, 7 insertions, 3 deletions
diff --git a/attr.h b/attr.h
index 4634001..3daca3c 100644
--- a/attr.h
+++ b/attr.h
@@ -1,6 +1,8 @@
#ifndef ATTR_H
#define ATTR_H
+struct index_state;
/* An attribute is a pointer to this opaque structure */
struct git_attr;
@@ -60,13 +62,15 @@ void attr_check_free(struct attr_check *check);
const char *git_attr_name(const struct git_attr *);
-int git_check_attr(const char *path, struct attr_check *check);
+int git_check_attr(const struct index_state *istate,
+ const char *path, struct attr_check *check);
* Retrieve all attributes that apply to the specified path.
* check holds the attributes and their values.
-void git_all_attrs(const char *path, struct attr_check *check);
+void git_all_attrs(const struct index_state *istate,
+ const char *path, struct attr_check *check);
enum git_attr_direction {
@@ -74,7 +78,7 @@ enum git_attr_direction {
void git_attr_set_direction(enum git_attr_direction new_direction,
- struct index_state *istate);
+ const struct index_state *istate);
void attr_start(void);