summaryrefslogtreecommitdiff
path: root/src/attr_file.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-03-02 03:51:45 +0100
committerVicent Martí <tanoku@gmail.com>2012-03-02 03:51:45 +0100
commitc63793ee81ee6961b2430e88379d491fa8e91bfb (patch)
tree2a754dec992f12a21afb19925622682c71c7b1fc /src/attr_file.c
parent47a899ffed3c71080e10e73eda092a716f1be168 (diff)
downloadlibgit2-c63793ee81ee6961b2430e88379d491fa8e91bfb.tar.gz
attr: Change the attribute check macros
The point of having `GIT_ATTR_TRUE` and `GIT_ATTR_FALSE` macros is to be able to change the way that true and false values are stored inside of the returned gitattributes value pointer. However, if these macros are implemented as a simple rename for the `git_attr__true` pointer, they will always be used with the `==` operator, and hence we cannot really change the implementation to any other way that doesn't imply using special pointer values and comparing them! We need to do the same thing that core Git does, which is using a function macro. With `GIT_ATTR_TRUE(attr)`, we can change internally the way that these values are stored to anything we want. This commit does that, and rewrites a large chunk of the attributes test suite to remove duplicated code for expected attributes, and to properly test the function macro behavior instead of comparing pointers.
Diffstat (limited to 'src/attr_file.c')
-rw-r--r--src/attr_file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index a1b69a5bb..3783b5ef3 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -458,12 +458,12 @@ int git_attr_assignment__parse(
}
assign->name_hash = 5381;
- assign->value = GIT_ATTR_TRUE;
+ assign->value = git_attr__true;
assign->is_allocated = 0;
/* look for magic name prefixes */
if (*scan == '-') {
- assign->value = GIT_ATTR_FALSE;
+ assign->value = git_attr__false;
scan++;
} else if (*scan == '!') {
assign->value = NULL; /* explicit unspecified state */
@@ -510,7 +510,7 @@ int git_attr_assignment__parse(
}
/* expand macros (if given a repo with a macro cache) */
- if (repo != NULL && assign->value == GIT_ATTR_TRUE) {
+ if (repo != NULL && assign->value == git_attr__true) {
git_attr_rule *macro =
git_hashtable_lookup(repo->attrcache.macros, assign->name);