diff src/org/tmatesoft/hg/internal/PathGlobMatcher.java @ 118:68ba22a2133a

Defects in the filter initialization
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 04 Feb 2011 02:44:32 +0100
parents 46291ec605a0
children 7567f4a42fe5
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/PathGlobMatcher.java	Fri Feb 04 02:12:30 2011 +0100
+++ b/src/org/tmatesoft/hg/internal/PathGlobMatcher.java	Fri Feb 04 02:44:32 2011 +0100
@@ -58,12 +58,16 @@
 		boolean needLineEndMatch = glob.charAt(end) != '*';
 		while (end > 0 && glob.charAt(end) == '*') end--; // remove trailing * that are useless for Pattern.find()
 		StringBuilder sb = new StringBuilder(end*2);
+		if (glob.charAt(0) != '*') {
+			sb.append('^');
+		}
 		for (int i = 0; i <= end; i++) {
 			char ch = glob.charAt(i);
 			if (ch == '*') {
 				if (glob.charAt(i+1) == '*') { // i < end because we've stripped any trailing * earlier
 					// any char, including path segment separator
 					sb.append(".*?");
+					i++;
 				} else {
 					// just path segments
 					sb.append("[^/]*?");