summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2017-08-11 21:16:54 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2017-08-11 21:59:49 +0200
commit4bc539a8141e8099587536620bdc555c2c4cb01e (patch)
tree6cf4fda594209cf3e35d3a1e569a80ec086a0816 /org.eclipse.jgit.test
parent22201e8cca3b2b1f6df71fb1053c7358a9a2d72f (diff)
downloadjgit-4bc539a8141e8099587536620bdc555c2c4cb01e.tar.gz
jgit-4bc539a8141e8099587536620bdc555c2c4cb01e.zip
Use relative paths for attribute rule matching
Attribute rules must match against the entry path relative to the attribute node containing the rule. The global entry path is to be used only for the init and the global node (and of course the root node). Bug: 520677 Change-Id: I80389a2dc272a72312729ccd5358d7c75e1ea20a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
index ca456b3c8a..50d020c57c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesHandlerTest.java
@@ -254,6 +254,33 @@ public class AttributesHandlerTest extends RepositoryTestCase {
endWalk();
}
+ @Test
+ public void testRelativePaths() throws Exception {
+ setupRepo("sub/ global", "sub/** init",
+ "sub/** top_sub\n*.txt top",
+ "sub/** subsub\nsub/ subsub2\n*.txt foo");
+ // The last two sub/** and sub/ rules are in sub/.gitattributes. They
+ // must not apply to any of the files here. They would match for a
+ // further subdirectory sub/sub.
+ walk = beginWalk();
+ assertIteration(F, ".gitattributes");
+ assertIteration(D, "sub", attrs("global"));
+ assertIteration(F, "sub/.gitattributes", attrs("init top_sub global"));
+ assertIteration(F, "sub/a.txt", attrs("init foo top top_sub global"));
+ endWalk();
+ // All right, let's see that they *do* apply in sub/sub:
+ writeTrashFile("sub/sub/b.txt", "b");
+ walk = beginWalk();
+ assertIteration(F, ".gitattributes");
+ assertIteration(D, "sub", attrs("global"));
+ assertIteration(F, "sub/.gitattributes", attrs("init top_sub global"));
+ assertIteration(F, "sub/a.txt", attrs("init foo top top_sub global"));
+ assertIteration(D, "sub/sub", attrs("init subsub2 top_sub global"));
+ assertIteration(F, "sub/sub/b.txt",
+ attrs("init foo subsub2 subsub top top_sub global"));
+ endWalk();
+ }
+
private static Collection<Attribute> attrs(String s) {
return new AttributesRule("*", s).getAttributes();
}