summaryrefslogtreecommitdiff
path: root/src/crlf.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/crlf.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/crlf.c')
-rw-r--r--src/crlf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/crlf.c b/src/crlf.c
index feaa687ee..e74f8e89b 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -25,13 +25,13 @@ struct crlf_filter {
static int check_crlf(const char *value)
{
- if (value == git_attr__true)
+ if (GIT_ATTR_TRUE(value))
return GIT_CRLF_TEXT;
- if (value == git_attr__false)
+ if (GIT_ATTR_FALSE(value))
return GIT_CRLF_BINARY;
- if (value == NULL)
+ if (GIT_ATTR_UNSPECIFIED(value))
return GIT_CRLF_GUESS;
if (strcmp(value, "input") == 0)
@@ -45,7 +45,7 @@ static int check_crlf(const char *value)
static int check_eol(const char *value)
{
- if (value == NULL)
+ if (GIT_ATTR_UNSPECIFIED(value))
return GIT_EOL_UNSET;
if (strcmp(value, "lf") == 0)