]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Fix 'grep' search for multiple matches in file
authorJakub Narebski <redacted>
Wed, 15 Feb 2012 16:37:06 +0000 (17:37 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:32 +0000 (00:51 -0400)
Commit ff7f218 (gitweb: Fix file links in "grep" search, 2012-01-05),
added $file_href variable, to reduce duplication and have the fix
applied in single place.

Unfortunately it made variable defined inside the loop, not taking into
account the fact that $file_href was set only if file changed.
Therefore for files with multiple matches $file_href was undefined for
second and subsequent matches.

Fix this bug by moving $file_href declaration outside loop.

Adds tests for almost all forms of sarch in gitweb, which were missing
from testuite.  Note that it only tests if there are no warnings, and
it doesn't check that gitweb finds what it should find.

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

index 1ab150d59d7571948e864bf4052561d9969748bd2aab3a4de84eefe4c1816b6e..8ed2ba1a5dcc297881158ee7af5ca001e4121a6b6c671106ea95c155eafcf5be 100755 (executable)
@@ -5916,9 +5916,10 @@ sub git_search_files {
        my $alternate = 1;
        my $matches = 0;
        my $lastfile = '';
        my $alternate = 1;
        my $matches = 0;
        my $lastfile = '';
+       my $file_href;
        while (my $line = <$fd>) {
                chomp $line;
        while (my $line = <$fd>) {
                chomp $line;
-               my ($file, $file_href, $lno, $ltext, $binary);
+               my ($file, $lno, $ltext, $binary);
                last if ($matches++ > 1000);
                if ($line =~ /^Binary file (.+) matches$/) {
                        $file = $1;
                last if ($matches++ > 1000);
                if ($line =~ /^Binary file (.+) matches$/) {
                        $file = $1;
This page took 0.334768 seconds and 4 git commands to generate.