changeset 343:58016b1b8554

HgIgnore: glob patterns not to match substring when not meant to
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 19 Nov 2011 01:07:27 +0100
parents 516b817415ba
children 168f1994de7e
files src/org/tmatesoft/hg/repo/HgIgnore.java test/org/tmatesoft/hg/test/TestIgnore.java
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgIgnore.java	Fri Nov 18 05:10:33 2011 +0100
+++ b/src/org/tmatesoft/hg/repo/HgIgnore.java	Sat Nov 19 01:07:27 2011 +0100
@@ -160,6 +160,7 @@
 			}
 			sb.append(ch);
 		}
+		sb.append("(?:/|$)");
 		return sb.toString();
 	}
 
--- a/test/org/tmatesoft/hg/test/TestIgnore.java	Fri Nov 18 05:10:33 2011 +0100
+++ b/test/org/tmatesoft/hg/test/TestIgnore.java	Sat Nov 19 01:07:27 2011 +0100
@@ -88,6 +88,14 @@
 		for (Path p : toCheck) {
 			errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p));
 		}
+		s = "syntax:glob\n.git";
+		hgIgnore = HgInternals.newHgIgnore(new StringReader(s));
+		Path p = Path.create(".git/aa");
+		errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p));
+		p = Path.create("dir/.git/bb");
+		errorCollector.assertTrue(p.toString(), hgIgnore.isIgnored(p));
+		p = Path.create("dir/.gittt/cc");
+		errorCollector.assertTrue(p.toString(), !hgIgnore.isIgnored(p));
 	}
 
 	@Test