@@ -5836,7 +5836,7 @@ sub git_search_files {
58365836 my %co = @_ ;
58375837
58385838 local $/ = " \n " ;
5839- open my $fd , " -|" , git_cmd(), ' grep' , ' -n' ,
5839+ open my $fd , " -|" , git_cmd(), ' grep' , ' -n' , ' -z ' ,
58405840 $search_use_regexp ? (' -E' , ' -i' ) : ' -F' ,
58415841 $searchtext , $co {' tree' }
58425842 or die_error(500, " Open git-grep failed" );
@@ -5852,13 +5852,14 @@ sub git_search_files {
58525852 my $lastfile = ' ' ;
58535853 while (my $line = <$fd >) {
58545854 chomp $line ;
5855- my ($file , $lno , $ltext , $binary );
5855+ my ($file , $file_href , $ lno , $ltext , $binary );
58565856 last if ($matches ++ > 1000);
58575857 if ($line =~ / ^Binary file (.+) matches$ / ) {
58585858 $file = $1 ;
58595859 $binary = 1;
58605860 } else {
5861- (undef , $file , $lno , $ltext ) = split (/ :/ , $line , 4);
5861+ ($file , $lno , $ltext ) = split (/ \0 / , $line , 3);
5862+ $file =~ s / ^$co{'tree'}:// ;
58625863 }
58635864 if ($file ne $lastfile ) {
58645865 $lastfile and print " </td></tr>\n " ;
@@ -5867,10 +5868,10 @@ sub git_search_files {
58675868 } else {
58685869 print " <tr class=\" light\" >\n " ;
58695870 }
5871+ $file_href = href(action => " blob" , hash_base => $co {' id' },
5872+ file_name => $file );
58705873 print " <td class=\" list\" >" .
5871- $cgi -> a({-href => href(action => " blob" , hash => $co {' hash' },
5872- file_name => " $file " ),
5873- -class => " list" }, esc_path($file ));
5874+ $cgi -> a({-href => $file_href , -class => " list" }, esc_path($file ));
58745875 print " </td><td>\n " ;
58755876 $lastfile = $file ;
58765877 }
@@ -5888,10 +5889,9 @@ sub git_search_files {
58885889 $ltext = esc_html($ltext , -nbsp => 1);
58895890 }
58905891 print " <div class=\" pre\" >" .
5891- $cgi -> a({-href => href(action => " blob" , hash => $co {' hash' },
5892- file_name => " $file " ).' #l' .$lno ,
5893- -class => " linenr" }, sprintf (' %4i' , $lno ))
5894- . ' ' . $ltext . " </div>\n " ;
5892+ $cgi -> a({-href => $file_href .' #l' .$lno ,
5893+ -class => " linenr" }, sprintf (' %4i' , $lno )) .
5894+ ' ' . $ltext . " </div>\n " ;
58955895 }
58965896 }
58975897 if ($lastfile ) {
0 commit comments