summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attr.c19
-rw-r--r--src/attr_file.c12
-rw-r--r--src/attr_file.h4
3 files changed, 27 insertions, 8 deletions
diff --git a/src/attr.c b/src/attr.c
index 6fbd005d5..1c511993b 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -5,6 +5,25 @@
GIT__USE_STRMAP;
+const char *git_attr__true = "[internal]__TRUE__";
+const char *git_attr__false = "[internal]__FALSE__";
+const char *git_attr__unset = "[internal]__UNSET__";
+
+git_attr_t git_attr_value(const char *attr)
+{
+ if (attr == NULL || attr == git_attr__unset)
+ return GIT_ATTR_UNSPECIFIED_T;
+
+ if (attr == git_attr__true)
+ return GIT_ATTR_TRUE_T;
+
+ if (attr == git_attr__false)
+ return GIT_ATTR_FALSE_T;
+
+ return GIT_ATTR_VALUE_T;
+}
+
+
static int collect_attr_files(
git_repository *repo,
uint32_t flags,
diff --git a/src/attr_file.c b/src/attr_file.c
index 837c42d8e..966da4069 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -5,10 +5,6 @@
#include "git2/tree.h"
#include <ctype.h>
-const char *git_l_attr__true = "[internal]__TRUE__";
-const char *git_l_attr__false = "[internal]__FALSE__";
-const char *git_l_attr__unset = "[internal]__UNSET__";
-
static int sort_by_hash_and_name(const void *a_raw, const void *b_raw);
static void git_attr_rule__clear(git_attr_rule *rule);
@@ -493,14 +489,14 @@ int git_attr_assignment__parse(
}
assign->name_hash = 5381;
- assign->value = git_l_attr__true;
+ assign->value = git_attr__true;
/* look for magic name prefixes */
if (*scan == '-') {
- assign->value = git_l_attr__false;
+ assign->value = git_attr__false;
scan++;
} else if (*scan == '!') {
- assign->value = git_l_attr__unset; /* explicit unspecified state */
+ assign->value = git_attr__unset; /* explicit unspecified state */
scan++;
} else if (*scan == '#') /* comment rest of line */
break;
@@ -536,7 +532,7 @@ int git_attr_assignment__parse(
}
/* expand macros (if given a repo with a macro cache) */
- if (repo != NULL && assign->value == git_l_attr__true) {
+ if (repo != NULL && assign->value == git_attr__true) {
git_attr_rule *macro =
git_attr_cache__lookup_macro(repo, assign->name);
diff --git a/src/attr_file.h b/src/attr_file.h
index 7939f838a..9d6730d90 100644
--- a/src/attr_file.h
+++ b/src/attr_file.h
@@ -24,6 +24,10 @@
#define GIT_ATTR_FNMATCH_HASWILD (1U << 5)
#define GIT_ATTR_FNMATCH_ALLOWSPACE (1U << 6)
+extern const char *git_attr__true;
+extern const char *git_attr__false;
+extern const char *git_attr__unset;
+
typedef struct {
char *pattern;
size_t length;