From c63793ee81ee6961b2430e88379d491fa8e91bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicent=20Mart=C3=AD?= Date: Fri, 2 Mar 2012 03:51:45 +0100 Subject: 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. --- src/attr_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/attr_file.c') 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); -- cgit v1.2.3