diff options
| author | Vicent Martà <tanoku@gmail.com> | 2012-03-02 03:51:45 +0100 |
|---|---|---|
| committer | Vicent Martà <tanoku@gmail.com> | 2012-03-02 03:51:45 +0100 |
| commit | c63793ee81ee6961b2430e88379d491fa8e91bfb (patch) | |
| tree | 2a754dec992f12a21afb19925622682c71c7b1fc /include/git2/attr.h | |
| parent | 47a899ffed3c71080e10e73eda092a716f1be168 (diff) | |
| download | libgit2-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 'include/git2/attr.h')
| -rw-r--r-- | include/git2/attr.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/git2/attr.h b/include/git2/attr.h index 7e8bb9fe8..81d1e517b 100644 --- a/include/git2/attr.h +++ b/include/git2/attr.h @@ -19,12 +19,12 @@ */ GIT_BEGIN_DECL -#define GIT_ATTR_TRUE git_attr__true -#define GIT_ATTR_FALSE git_attr__false -#define GIT_ATTR_UNSPECIFIED NULL +#define GIT_ATTR_TRUE(attr) ((attr) == git_attr__true) +#define GIT_ATTR_FALSE(attr) ((attr) == git_attr__false) +#define GIT_ATTR_UNSPECIFIED(attr) ((attr) == NULL) -GIT_EXTERN(const char *)git_attr__true; -GIT_EXTERN(const char *)git_attr__false; +GIT_EXTERN(const char *) git_attr__true; +GIT_EXTERN(const char *) git_attr__false; /** |
