aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorAndrey Loskutov <loskutov@gmx.de>2015-07-15 21:07:35 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2015-07-21 01:23:40 +0200
commitdfed946f10e17e4862328f3e6c1912618e33193f (patch)
tree86277bf51dc34044421bb68df7cdfb9a05e135c4 /org.eclipse.jgit.test
parentb98c84eb88e503e250274b62eaff000c071c62a4 (diff)
downloadjgit-dfed946f10e17e4862328f3e6c1912618e33193f.tar.gz
jgit-dfed946f10e17e4862328f3e6c1912618e33193f.zip
Allow leading/trailing spaces in ignore rules
According to [1] leading spaces are allowed in ignore rules and trailing spaces are allowed too if they are escaped via backslash. [1] https://www.kernel.org/pub/software/scm/git/docs/gitignore.html Bug: 472762 Change-Id: I5e3ae5599cb9e5d80072f38c82c20cbc9475a18a Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java61
1 files changed, 61 insertions, 0 deletions
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 571f3186d7..17e2e9961e 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
@@ -375,6 +375,67 @@ public class IgnoreNodeTest extends RepositoryTestCase {
}
@Test
+ public void testLeadingSpaces() throws IOException {
+ writeTrashFile(" a/ a", "");
+ writeTrashFile(" a/ a", "");
+ writeTrashFile(" a/a", "");
+ writeTrashFile(" a/ a", "");
+ writeTrashFile(" a/ a", "");
+ writeTrashFile(" a/a", "");
+ writeIgnoreFile(".gitignore", " a", " a");
+ writeTrashFile("a/ a", "");
+ writeTrashFile("a/ a", "");
+ writeTrashFile("a/a", "");
+
+ beginWalk();
+ assertEntry(D, ignored, " a");
+ assertEntry(F, ignored, " a/ a");
+ assertEntry(F, ignored, " a/ a");
+ assertEntry(F, ignored, " a/a");
+ assertEntry(D, ignored, " a");
+ assertEntry(F, ignored, " a/ a");
+ assertEntry(F, ignored, " a/ a");
+ assertEntry(F, ignored, " a/a");
+ assertEntry(F, tracked, ".gitignore");
+ assertEntry(D, tracked, "a");
+ assertEntry(F, ignored, "a/ a");
+ assertEntry(F, ignored, "a/ a");
+ assertEntry(F, tracked, "a/a");
+ endWalk();
+ }
+
+ @Test
+ public void testTrailingSpaces() throws IOException {
+ writeTrashFile("a /a", "");
+ writeTrashFile("a /a ", "");
+ writeTrashFile("a /a ", "");
+ writeTrashFile("a /a", "");
+ writeTrashFile("a /a ", "");
+ writeTrashFile("a /a ", "");
+ writeTrashFile("a/a", "");
+ writeTrashFile("a/a ", "");
+ writeTrashFile("a/a ", "");
+
+ writeIgnoreFile(".gitignore", "a\\ ", "a \\ ");
+
+ beginWalk();
+ assertEntry(F, tracked, ".gitignore");
+ assertEntry(D, ignored, "a ");
+ assertEntry(F, ignored, "a /a");
+ assertEntry(F, ignored, "a /a ");
+ assertEntry(F, ignored, "a /a ");
+ assertEntry(D, ignored, "a ");
+ assertEntry(F, ignored, "a /a");
+ assertEntry(F, ignored, "a /a ");
+ assertEntry(F, ignored, "a /a ");
+ assertEntry(D, tracked, "a");
+ assertEntry(F, tracked, "a/a");
+ assertEntry(F, ignored, "a/a ");
+ assertEntry(F, ignored, "a/a ");
+ endWalk();
+ }
+
+ @Test
public void testToString() throws Exception {
assertEquals(Arrays.asList("").toString(), new IgnoreNode().toString());
assertEquals(Arrays.asList("hello").toString(),