]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Mark first match when searching commit messages
authorJakub Narebski <redacted>
Sun, 2 Mar 2008 15:57:14 +0000 (16:57 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:12 +0000 (00:07 -0400)
Due to greediness of a pattern, gitweb used to mark (show) last match
in line, if there are more than one match in line. Now it shows first.
Showing all matches in a line would require further work.

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 1ea603076246c788dde44a914964ca0178a216a88451d26ad536d0d436018b33..00e35dc844a5fcdfed23b6e04192c07cb875997efb1dc6ac42742025781374fc 100755 (executable)
@@ -3838,7 +3838,7 @@ sub git_search_grep_body {
                              chop_and_escape_str($co{'title'}, 50) . "<br/>");
                my $comment = $co{'comment'};
                foreach my $line (@$comment) {
                              chop_and_escape_str($co{'title'}, 50) . "<br/>");
                my $comment = $co{'comment'};
                foreach my $line (@$comment) {
-                       if ($line =~ m/^(.*)($search_regexp)(.*)$/i) {
+                       if ($line =~ m/^(.*?)($search_regexp)(.*)$/i) {
                                my ($lead, $match, $trail) = ($1, $2, $3);
                                $match = chop_str($match, 70, 5, 'center');
                                my $contextlen = int((80 - length($match))/2);
                                my ($lead, $match, $trail) = ($1, $2, $3);
                                $match = chop_str($match, 70, 5, 'center');
                                my $contextlen = int((80 - length($match))/2);
This page took 0.302515 seconds and 4 git commands to generate.