On Mon, May 16, 2016 at 10:03 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > When matching (i.e. the match_attrs() function), you would instead > do > > path = xmemdupz(name, namelen); > git_check_attr(path, item->attr_check); > > to grab values for only attributes that matter to you, instead of > calling git_all_attrs() [*2*]. > > After git_check_attr() returns, item->attr_check.check[0].attr would > be git_attr("VAR1") and item->attr_check.check[0].value would be > whatever setting the path has for the VAR1 attribute. You can use > your match_mode logic to compare it with the values .attr_match > expects. > > You do not necessarily have to have the same number of elements in > .attr_match and .attr_check.check by the way. .attr_match might say > > VAR1=VAL2 !VAR1 -VAR1 > > which may be always false if these are ANDed together, but in order > to evaluate it, you need only one git_attr_check_elem for VAR1. So for the matching we would need to get the order right, i.e. const char *inspect_name = git_attr_name(item.attr_match[i].attr); for (j=0; j < p.attr_check.check_nr; j++) { const char *cur_name = git_attr_name(p.attr_check.check[j].attr); if (!strcmp(inspect_name, cur_name)) break; // now compare .attr_match[i] with attr_check.check[j] This doesn't look cheap to me? Am I holding it wrong again? -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html