attr: more matching optimizations from .gitignore

.gitattributes and .gitignore share the same pattern syntax but has
separate matching implementation. Over the years, ignore's
implementation accumulates more optimizations while attr's stays the
same.

This patch reuses the core matching functions that are also used by
excluded_from_list. excluded_from_list and path_matches can't be
merged due to differences in exclude and attr, for example:

* "!pattern" syntax is forbidden in .gitattributes.  As an attribute
  can be unset (i.e. set to a special value "false") or made back to
  unspecified (i.e. not even set to "false"), "!pattern attr" is unclear
  which one it means.

* we support attaching attributes to directories, but git-core
  internally does not currently make use of attributes on
  directories.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 files changed
tree: c521a6c799d79527e70672291afa0aa1e57da817
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. git_remote_helpers/
  8. gitk-git/
  9. gitweb/
  10. mergetools/
  11. perl/
  12. po/
  13. ppc/
  14. t/
  15. templates/
  16. vcs-svn/
  17. xdiff/
  18. .gitattributes
  19. .gitignore
  20. .mailmap
  21. abspath.c
  22. aclocal.m4
  23. advice.c
  24. advice.h
  25. alias.c
  26. alloc.c
  27. archive-tar.c
  28. archive-zip.c
  29. archive.c
  30. archive.h
  31. argv-array.c
  32. argv-array.h
  33. attr.c
  34. attr.h
  35. base85.c
  36. bisect.c
  37. bisect.h
  38. blob.c
  39. blob.h
  40. branch.c
  41. branch.h
  42. builtin.h
  43. bulk-checkin.c
  44. bulk-checkin.h
  45. bundle.c
  46. bundle.h
  47. cache-tree.c
  48. cache-tree.h
  49. cache.h
  50. check-builtins.sh
  51. check-racy.c
  52. check_bindir
  53. color.c
  54. color.h
  55. column.c
  56. column.h
  57. combine-diff.c
  58. command-list.txt
  59. commit.c
  60. commit.h
  61. config.c
  62. config.mak.in
  63. configure.ac
  64. connect.c
  65. connected.c
  66. connected.h
  67. convert.c
  68. convert.h
  69. copy.c
  70. COPYING
  71. credential-cache--daemon.c
  72. credential-cache.c
  73. credential-store.c
  74. credential.c
  75. credential.h
  76. csum-file.c
  77. csum-file.h
  78. ctype.c
  79. daemon.c
  80. date.c
  81. decorate.c
  82. decorate.h
  83. delta.h
  84. diff-delta.c
  85. diff-lib.c
  86. diff-no-index.c
  87. diff.c
  88. diff.h
  89. diffcore-break.c
  90. diffcore-delta.c
  91. diffcore-order.c
  92. diffcore-pickaxe.c
  93. diffcore-rename.c
  94. diffcore.h
  95. dir.c
  96. dir.h
  97. editor.c
  98. entry.c
  99. environment.c
  100. exec_cmd.c
  101. exec_cmd.h
  102. fast-import.c
  103. fetch-pack.h
  104. fixup-builtins
  105. fmt-merge-msg.h
  106. fsck.c
  107. fsck.h
  108. generate-cmdlist.sh
  109. gettext.c
  110. gettext.h
  111. git-add--interactive.perl
  112. git-am.sh
  113. git-archimport.perl
  114. git-bisect.sh
  115. git-compat-util.h
  116. git-cvsexportcommit.perl
  117. git-cvsimport.perl
  118. git-cvsserver.perl
  119. git-difftool--helper.sh
  120. git-difftool.perl
  121. git-filter-branch.sh
  122. git-instaweb.sh
  123. git-lost-found.sh
  124. git-merge-octopus.sh
  125. git-merge-one-file.sh
  126. git-merge-resolve.sh
  127. git-mergetool--lib.sh
  128. git-mergetool.sh
  129. git-p4.py
  130. git-parse-remote.sh
  131. git-pull.sh
  132. git-quiltimport.sh
  133. git-rebase--am.sh
  134. git-rebase--interactive.sh
  135. git-rebase--merge.sh
  136. git-rebase.sh
  137. git-relink.perl
  138. git-remote-testgit.py
  139. git-repack.sh
  140. git-request-pull.sh
  141. git-send-email.perl
  142. git-sh-i18n.sh
  143. git-sh-setup.sh
  144. git-stash.sh
  145. git-submodule.sh
  146. git-svn.perl
  147. GIT-VERSION-GEN
  148. git-web--browse.sh
  149. git.c
  150. git.spec.in
  151. gpg-interface.c
  152. gpg-interface.h
  153. graph.c
  154. graph.h
  155. grep.c
  156. grep.h
  157. hash.c
  158. hash.h
  159. help.c
  160. help.h
  161. hex.c
  162. http-backend.c
  163. http-fetch.c
  164. http-push.c
  165. http-walker.c
  166. http.c
  167. http.h
  168. ident.c
  169. imap-send.c
  170. INSTALL
  171. kwset.c
  172. kwset.h
  173. levenshtein.c
  174. levenshtein.h
  175. LGPL-2.1
  176. list-objects.c
  177. list-objects.h
  178. ll-merge.c
  179. ll-merge.h
  180. lockfile.c
  181. log-tree.c
  182. log-tree.h
  183. mailmap.c
  184. mailmap.h
  185. Makefile
  186. match-trees.c
  187. merge-file.c
  188. merge-file.h
  189. merge-recursive.c
  190. merge-recursive.h
  191. mergesort.c
  192. mergesort.h
  193. name-hash.c
  194. notes-cache.c
  195. notes-cache.h
  196. notes-merge.c
  197. notes-merge.h
  198. notes.c
  199. notes.h
  200. object.c
  201. object.h
  202. pack-check.c
  203. pack-refs.c
  204. pack-refs.h
  205. pack-revindex.c
  206. pack-revindex.h
  207. pack-write.c
  208. pack.h
  209. pager.c
  210. parse-options-cb.c
  211. parse-options.c
  212. parse-options.h
  213. patch-delta.c
  214. patch-ids.c
  215. patch-ids.h
  216. path.c
  217. pkt-line.c
  218. pkt-line.h
  219. preload-index.c
  220. pretty.c
  221. progress.c
  222. progress.h
  223. prompt.c
  224. prompt.h
  225. quote.c
  226. quote.h
  227. reachable.c
  228. reachable.h
  229. read-cache.c
  230. README
  231. reflog-walk.c
  232. reflog-walk.h
  233. refs.c
  234. refs.h
  235. remote-curl.c
  236. remote.c
  237. remote.h
  238. replace_object.c
  239. rerere.c
  240. rerere.h
  241. resolve-undo.c
  242. resolve-undo.h
  243. revision.c
  244. revision.h
  245. run-command.c
  246. run-command.h
  247. send-pack.h
  248. sequencer.c
  249. sequencer.h
  250. server-info.c
  251. setup.c
  252. sh-i18n--envsubst.c
  253. sha1-array.c
  254. sha1-array.h
  255. sha1-lookup.c
  256. sha1-lookup.h
  257. sha1_file.c
  258. sha1_name.c
  259. shallow.c
  260. shell.c
  261. shortlog.h
  262. show-index.c
  263. sideband.c
  264. sideband.h
  265. sigchain.c
  266. sigchain.h
  267. strbuf.c
  268. strbuf.h
  269. streaming.c
  270. streaming.h
  271. string-list.c
  272. string-list.h
  273. submodule.c
  274. submodule.h
  275. symlinks.c
  276. tag.c
  277. tag.h
  278. tar.h
  279. test-chmtime.c
  280. test-credential.c
  281. test-ctype.c
  282. test-date.c
  283. test-delta.c
  284. test-dump-cache-tree.c
  285. test-genrandom.c
  286. test-index-version.c
  287. test-line-buffer.c
  288. test-match-trees.c
  289. test-mergesort.c
  290. test-mktemp.c
  291. test-parse-options.c
  292. test-path-utils.c
  293. test-regex.c
  294. test-revision-walking.c
  295. test-run-command.c
  296. test-scrap-cache-tree.c
  297. test-sha1.c
  298. test-sha1.sh
  299. test-sigchain.c
  300. test-subprocess.c
  301. test-svn-fe.c
  302. thread-utils.c
  303. thread-utils.h
  304. trace.c
  305. transport-helper.c
  306. transport.c
  307. transport.h
  308. tree-diff.c
  309. tree-walk.c
  310. tree-walk.h
  311. tree.c
  312. tree.h
  313. unimplemented.sh
  314. unix-socket.c
  315. unix-socket.h
  316. unpack-trees.c
  317. unpack-trees.h
  318. upload-pack.c
  319. url.c
  320. url.h
  321. usage.c
  322. userdiff.c
  323. userdiff.h
  324. utf8.c
  325. utf8.h
  326. varint.c
  327. varint.h
  328. walker.c
  329. walker.h
  330. wrap-for-bin.sh
  331. wrapper.c
  332. write_or_die.c
  333. ws.c
  334. wt-status.c
  335. wt-status.h
  336. xdiff-interface.c
  337. xdiff-interface.h
  338. zlib.c