Only match on basename of filename
Only match on basename of filename

--- a/include/display.git_search_files.php
+++ b/include/display.git_search_files.php
@@ -81,7 +81,16 @@
 		$tpl->assign("project",$project);
 		$tpl->assign("hashbase",$hash);
 		$tpl->assign("file",$file);
-		$hlt = highlight($file, $search, "searchmatch");
+		if (strpos($file,"/") !== false) {
+			$f = basename($file);
+			$d = dirname($file);
+			if ($d == "/")
+				$d = "";
+			$hlt = highlight($f, $search, "searchmatch");
+			if ($hlt)
+				$hlt = $d . "/" . $hlt;
+		} else
+			$hlt = highlight($file, $search, "searchmatch");
 		if ($hlt)
 			$tpl->assign("filename",$hlt);
 		else

--- a/include/gitutil.git_filesearch.php
+++ b/include/gitutil.git_filesearch.php
@@ -47,9 +47,9 @@
 			$matches[$fname]['type'] = $regs[2];
 		} else {
 			if ($case)
-				$ret = ereg("^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.*" . quotemeta($search) . ".*)",$line,$regs);
+				$ret = ereg("^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.*" . quotemeta($search) . "[^/]*)$",$line,$regs);
 			else
-				$ret = eregi("^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.*" . quotemeta($search) . ".*)",$line,$regs);
+				$ret = eregi("^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.*" . quotemeta($search) . "[^/]*)$",$line,$regs);
 			if ($ret) {
 				$fname = trim($regs[4]);
 				$matches[$fname] = array();

comments