diff options
author | Andrey Loskutov <loskutov@gmx.de> | 2015-07-16 00:23:37 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-07-21 01:23:40 +0200 |
commit | 4e7639bb656bf4c52d5925edfe34706a47c2548e (patch) | |
tree | dc0a67dbb02400a799d138cd19de6ec1faecb10f /org.eclipse.jgit | |
parent | dfed946f10e17e4862328f3e6c1912618e33193f (diff) | |
download | jgit-4e7639bb656bf4c52d5925edfe34706a47c2548e.tar.gz jgit-4e7639bb656bf4c52d5925edfe34706a47c2548e.zip |
Don't keep empty ignore rules in the ignore node list
Change-Id: Icd893dfaba06561bbe5cc60ebf866ec5d8301c22
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java | 5 |
2 files changed, 12 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java index 892d5ef8f5..e376cbba5d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java @@ -188,6 +188,14 @@ public class FastIgnoreRule { return !inverse; } + /** + * @return true if the rule never matches (comment line or broken pattern) + * @since 4.1 + */ + public boolean isEmpty() { + return matcher == NO_MATCH; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java index b20e525f5f..8b1244ed1b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java @@ -110,7 +110,10 @@ public class IgnoreNode { String txt; while ((txt = br.readLine()) != null) { if (txt.length() > 0 && !txt.startsWith("#") && !txt.equals("/")) { //$NON-NLS-1$ //$NON-NLS-2$ - rules.add(new FastIgnoreRule(txt)); + FastIgnoreRule rule = new FastIgnoreRule(txt); + if (!rule.isEmpty()) { + rules.add(rule); + } } } } |