23
#define ATTR__UNSET NULL
24
#define ATTR__UNKNOWN git_attr__unknown
25
26
-#ifndef DEBUG_ATTR
27
-#define DEBUG_ATTR 0
28
-#endif
29
-
26
struct git_attr {
27
int attr_nr; /* unique attribute number */
28
char name[FLEX_ARRAY]; /* attribute name */
803
return res;
804
}
805
810
-#if DEBUG_ATTR
811
-static void debug_info(const char *what, struct attr_stack *elem)
812
-{
813
- fprintf(stderr, "%s: %s\n", what, elem->origin ? elem->origin : "()");
814
-}
815
-static void debug_set(const char *what, const char *match, struct git_attr *attr, const void *v)
816
-{
817
- const char *value = v;
818
-
819
- if (ATTR_TRUE(value))
820
- value = "set";
821
- else if (ATTR_FALSE(value))
822
- value = "unset";
823
- else if (ATTR_UNSET(value))
824
- value = "unspecified";
825
-
826
- fprintf(stderr, "%s: %s => %s (%s)\n",
827
- what, attr->name, (char *) value, match);
828
-}
829
-#define debug_push(a) debug_info("push", (a))
830
-#define debug_pop(a) debug_info("pop", (a))
831
-#else
832
-#define debug_push(a) do { ; } while (0)
833
-#define debug_pop(a) do { ; } while (0)
834
-#define debug_set(a,b,c,d) do { ; } while (0)
835
-#endif /* DEBUG_ATTR */
836
-
806
static const char *git_etc_gitattributes(void)
807
{
808
static const char *system_wide;
923
(!namelen || path[namelen] == '/'))
924
break;
925
957
- debug_pop(elem);
926
*stack = elem->prev;
927
attr_stack_free(elem);
928
}
996
997
static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem);
998
1031
-static int fill_one(const char *what, struct all_attrs_item *all_attrs,
999
+static int fill_one(struct all_attrs_item *all_attrs,
1000
const struct match_attr *a, int rem)
1001
{
1002
int i;
1007
const char *v = a->state[i].setto;
1008
1009
if (*n == ATTR__UNKNOWN) {
1042
- debug_set(what,
1043
- a->is_macro ? a->u.attr->name : a->u.pat.pattern,
1044
- attr, v);
1010
*n = v;
1011
rem--;
1012
rem = macroexpand_one(all_attrs, attr->attr_nr, rem);
1029
continue;
1030
if (path_matches(path, pathlen, basename_offset,
1031
&a->u.pat, base, stack->originlen))
1067
- rem = fill_one("fill", all_attrs, a, rem);
1032
+ rem = fill_one(all_attrs, a, rem);
1033
}
1034
}
1035
1041
const struct all_attrs_item *item = &all_attrs[nr];
1042
1043
if (item->macro && item->value == ATTR__TRUE)
1079
- return fill_one("expand", all_attrs, item->macro, rem);
1044
+ return fill_one(all_attrs, item->macro, rem);
1045
else
1046
return rem;
1047
}