Skip to content

Commit 69c5f17

Browse files
peffgitster
authored andcommitted
attr: drop DEBUG_ATTR code
Since its inception in d0bfd02 (Add basic infrastructure to assign attributes to paths, 2007-04-12), the attribute code carries a little bit of debug code that is conditionally compiled only when DEBUG_ATTR is set. But since you have to know about it and make a special build of Git to use it, it's not clear that it's helping anyone (and there are very few mentions of it on the list over the years). Meanwhile, it causes slight headaches. Since it's not built as part of a regular compile, it's subject to bitrot. E.g., this was dealt with in 712efb1 (attr: make it build with DEBUG_ATTR again, 2013-01-15), and it currently fails to build with DEVELOPER=1 since e810e06 (attr: tighten const correctness with git_attr and match_attr, 2017-01-27). And it causes confusion with -Wunused-parameter; the "what" parameter of fill_one() is unused in a normal build, but needed in a debug build. Let's just get rid of this code (and the now-useless parameter). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 116761b commit 69c5f17

File tree

1 file changed

+3
-38
lines changed

1 file changed

+3
-38
lines changed

attr.c

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ static const char git_attr__unknown[] = "(builtin)unknown";
2323
#define ATTR__UNSET NULL
2424
#define ATTR__UNKNOWN git_attr__unknown
2525

26-
#ifndef DEBUG_ATTR
27-
#define DEBUG_ATTR 0
28-
#endif
29-
3026
struct git_attr {
3127
int attr_nr; /* unique attribute number */
3228
char name[FLEX_ARRAY]; /* attribute name */
@@ -807,33 +803,6 @@ static struct attr_stack *read_attr(struct index_state *istate,
807803
return res;
808804
}
809805

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-
837806
static const char *git_etc_gitattributes(void)
838807
{
839808
static const char *system_wide;
@@ -954,7 +923,6 @@ static void prepare_attr_stack(struct index_state *istate,
954923
(!namelen || path[namelen] == '/'))
955924
break;
956925

957-
debug_pop(elem);
958926
*stack = elem->prev;
959927
attr_stack_free(elem);
960928
}
@@ -1028,7 +996,7 @@ static int path_matches(const char *pathname, int pathlen,
1028996

1029997
static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem);
1030998

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,
10321000
const struct match_attr *a, int rem)
10331001
{
10341002
int i;
@@ -1039,9 +1007,6 @@ static int fill_one(const char *what, struct all_attrs_item *all_attrs,
10391007
const char *v = a->state[i].setto;
10401008

10411009
if (*n == ATTR__UNKNOWN) {
1042-
debug_set(what,
1043-
a->is_macro ? a->u.attr->name : a->u.pat.pattern,
1044-
attr, v);
10451010
*n = v;
10461011
rem--;
10471012
rem = macroexpand_one(all_attrs, attr->attr_nr, rem);
@@ -1064,7 +1029,7 @@ static int fill(const char *path, int pathlen, int basename_offset,
10641029
continue;
10651030
if (path_matches(path, pathlen, basename_offset,
10661031
&a->u.pat, base, stack->originlen))
1067-
rem = fill_one("fill", all_attrs, a, rem);
1032+
rem = fill_one(all_attrs, a, rem);
10681033
}
10691034
}
10701035

@@ -1076,7 +1041,7 @@ static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem)
10761041
const struct all_attrs_item *item = &all_attrs[nr];
10771042

10781043
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);
10801045
else
10811046
return rem;
10821047
}

0 commit comments

Comments
 (0)