949
PATHSPEC_LITERAL |
950
PATHSPEC_GLOB |
951
PATHSPEC_ICASE |
952
- PATHSPEC_EXCLUDE);
952
+ PATHSPEC_EXCLUDE |
953
+ PATHSPEC_ATTR);
954
955
if (!ps->nr) {
956
if (!ps->recursive ||
982
983
if (!ps->recursive ||
984
!(ps->magic & PATHSPEC_MAXDEPTH) ||
984
- ps->max_depth == -1)
985
- return all_entries_interesting;
986
-
987
- return within_depth(base_str + matchlen + 1,
988
- baselen - matchlen - 1,
989
- !!S_ISDIR(entry->mode),
990
- ps->max_depth) ?
991
- entry_interesting : entry_not_interesting;
985
+ ps->max_depth == -1) {
986
+ if (!item->attr_match_nr)
987
+ return all_entries_interesting;
988
+ else
989
+ goto interesting;
990
+ }
991
+
992
+ if (within_depth(base_str + matchlen + 1,
993
+ baselen - matchlen - 1,
994
+ !!S_ISDIR(entry->mode),
995
+ ps->max_depth))
996
+ goto interesting;
997
+ else
998
+ return entry_not_interesting;
999
}
1000
1001
/* Either there must be no base, or the base must match. */
1003
if (match_entry(item, entry, pathlen,
1004
match + baselen, matchlen - baselen,
1005
&never_interesting))
999
- return entry_interesting;
1006
+ goto interesting;
1007
1008
if (item->nowildcard_len < item->len) {
1009
if (!git_fnmatch(item, match + baselen, entry->path,
1010
item->nowildcard_len - baselen))
1004
- return entry_interesting;
1011
+ goto interesting;
1012
1013
/*
1014
* Match all directories. We'll try to
1029
!ps_strncmp(item, match + baselen,
1030
entry->path,
1031
item->nowildcard_len - baselen))
1025
- return entry_interesting;
1032
+ goto interesting;
1033
}
1034
1035
continue;
1064
if (!git_fnmatch(item, match, base->buf + base_offset,
1065
item->nowildcard_len)) {
1066
strbuf_setlen(base, base_offset + baselen);
1060
- return entry_interesting;
1067
+ goto interesting;
1068
}
1069
1070
/*
1078
!ps_strncmp(item, match, base->buf + base_offset,
1079
item->nowildcard_len)) {
1080
strbuf_setlen(base, base_offset + baselen);
1074
- return entry_interesting;
1081
+ goto interesting;
1082
}
1083
1084
strbuf_setlen(base, base_offset + baselen);
1092
*/
1093
if (ps->recursive && S_ISDIR(entry->mode))
1094
return entry_interesting;
1095
+ continue;
1096
+interesting:
1097
+ if (item->attr_match_nr) {
1098
+ int ret;
1099
+
1100
+ /*
1101
+ * Must not return all_entries_not_interesting
1102
+ * prematurely. We do not know if all entries do not
1103
+ * match some attributes with current attr API.
1104
+ */
1105
+ never_interesting = entry_not_interesting;
1106
+
1107
+ /*
1108
+ * Consider all directories interesting (because some
1109
+ * of those files inside may match some attributes
1110
+ * even though the parent dir does not)
1111
+ *
1112
+ * FIXME: attributes _can_ match directories and we
1113
+ * can probably return all_entries_interesting or
1114
+ * all_entries_not_interesting here if matched.
1115
+ */
1116
+ if (S_ISDIR(entry->mode))
1117
+ return entry_interesting;
1118
+
1119
+ strbuf_add(base, entry->path, pathlen);
1120
+ ret = match_pathspec_attrs(istate, base->buf + base_offset,
1121
+ base->len - base_offset, item);
1122
+ strbuf_setlen(base, base_offset + baselen);
1123
+ if (!ret)
1124
+ continue;
1125
+ }
1126
+ return entry_interesting;
1127
}
1128
return never_interesting; /* No matches */
1129
}