From 4e7639bb656bf4c52d5925edfe34706a47c2548e Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Thu, 16 Jul 2015 00:23:37 +0200 Subject: Don't keep empty ignore rules in the ignore node list Change-Id: Icd893dfaba06561bbe5cc60ebf866ec5d8301c22 Signed-off-by: Andrey Loskutov --- org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java | 8 ++++++++ org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'org.eclipse.jgit') 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); + } } } } -- cgit v1.2.3