summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorAndrey Loskutov <loskutov@gmx.de>2016-09-14 09:29:20 +0200
committerAndrey Loskutov <loskutov@gmx.de>2016-09-14 07:43:52 -0400
commit619329c84e41f9abe83616795d65af8c7fed5f3d (patch)
tree2d51137446b7d1950e6e2e008018d751e6a2c251 /org.eclipse.jgit.test/tst
parent57a263f1823d164142235a72072154f0568cb61c (diff)
downloadjgit-619329c84e41f9abe83616795d65af8c7fed5f3d.tar.gz
jgit-619329c84e41f9abe83616795d65af8c7fed5f3d.zip
Ignore trailing spaces in directory rule patterns
Bug: 500967 Change-Id: I7fabc2654af97011c62f46d5c30ee992341e45e2 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/BasicRuleTest.java28
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java11
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java5
3 files changed, 43 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/BasicRuleTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/BasicRuleTest.java
index d8a6174475..a6e48feea0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/BasicRuleTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/BasicRuleTest.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
+import org.eclipse.jgit.ignore.internal.Strings;
import org.junit.Test;
public class BasicRuleTest {
@@ -73,4 +74,31 @@ public class BasicRuleTest {
assertNotEquals(rule1.toString(), rule3.toString());
}
+ @Test
+ public void testDirectoryPattern() {
+ assertTrue(Strings.isDirectoryPattern("/"));
+ assertTrue(Strings.isDirectoryPattern("/ "));
+ assertTrue(Strings.isDirectoryPattern("/ "));
+ assertFalse(Strings.isDirectoryPattern(" "));
+ assertFalse(Strings.isDirectoryPattern(""));
+ }
+
+ @Test
+ public void testStripTrailingChar() {
+ assertEquals("", Strings.stripTrailing("/", '/'));
+ assertEquals("", Strings.stripTrailing("///", '/'));
+ assertEquals("a", Strings.stripTrailing("a/", '/'));
+ assertEquals("a", Strings.stripTrailing("a///", '/'));
+ assertEquals("a/ ", Strings.stripTrailing("a/ ", '/'));
+ }
+
+ @Test
+ public void testStripTrailingWhitespace() {
+ assertEquals("", Strings.stripTrailingWhitespace(""));
+ assertEquals("", Strings.stripTrailingWhitespace(" "));
+ assertEquals("a", Strings.stripTrailingWhitespace("a"));
+ assertEquals("a", Strings.stripTrailingWhitespace("a "));
+ assertEquals("a", Strings.stripTrailingWhitespace("a "));
+ assertEquals("a", Strings.stripTrailingWhitespace("a \t"));
+ }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java
index 480e326507..1863b80321 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/FastIgnoreRuleTest.java
@@ -123,6 +123,17 @@ public class FastIgnoreRuleTest {
}
@Test
+ public void testTrailingSpaces() {
+ assertMatched("a ", "a");
+ assertMatched("a/ ", "a/");
+ assertMatched("a/ ", "a/b");
+ assertMatched("a/\\ ", "a/ ");
+ assertNotMatched("a/\\ ", "a/");
+ assertNotMatched("a/\\ ", "a/b");
+ assertNotMatched("/ ", "a");
+ }
+
+ @Test
public void testAsteriskDot() {
assertMatched("*.a", ".a");
assertMatched("*.a", "/.a");
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
index c026efcde3..4a7dcd535f 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
@@ -480,8 +480,9 @@ public class IgnoreNodeTest extends RepositoryTestCase {
writeTrashFile("a/a", "");
writeTrashFile("a/a ", "");
writeTrashFile("a/a ", "");
+ writeTrashFile("b/c", "");
- writeIgnoreFile(".gitignore", "a\\ ", "a \\ ");
+ writeIgnoreFile(".gitignore", "a\\ ", "a \\ ", "b/ ");
beginWalk();
assertEntry(F, tracked, ".gitignore");
@@ -497,6 +498,8 @@ public class IgnoreNodeTest extends RepositoryTestCase {
assertEntry(F, tracked, "a/a");
assertEntry(F, ignored, "a/a ");
assertEntry(F, ignored, "a/a ");
+ assertEntry(D, ignored, "b");
+ assertEntry(F, ignored, "b/c");
endWalk();
}