]> source.dussan.org Git - jgit.git/commit
Fix path pattern matching to work also for gitattributes 21/103021/9
authorThomas Wolf <thomas.wolf@paranor.ch>
Sat, 12 Aug 2017 19:51:52 +0000 (21:51 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 27 Aug 2017 14:02:40 +0000 (16:02 +0200)
commitd80b999c76ef7c02c39810d071ec20acaf7d200a
treed4c2bd9fbe9a3ab39f324ce81cf84603b66369ae
parent08d4bef6b7db50398088974d0f9a7b0d52015f86
Fix path pattern matching to work also for gitattributes

Path pattern matching for attribute rules is different than matching
for excluded files.

The first difference concerns patterns without slashes. For
gitattributes those must match on the last component only, not on
any earlier segment. This is true also for directory-only patterns.

The second difference concerns directory-only patterns. Those also
must not match on a prefix or segment except the last one. They do
not apply recursively to all files beneath.

And third, matches only on a prefix must match for gitattributes
only if the last matcher was "/**".

Add a new parameter for such path matching to IMatcher.matches() and
pass it through as appropriate (false for gitignore, true for
gitattributes). As far as gitignore is concerned, there is no change.

New tests have been added, and some existing attribute matching tests
have been fixed since they operated on wrong assumptions.

Bug: 508568
Change-Id: Ie825dc2cac8a85a72a7eeb0abb888f3193d21dd2
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesMatcherTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/CGitAttributesTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/IMatcher.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/NameMatcher.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/WildMatcher.java