@@ -5836,7 +5836,7 @@ sub git_search_files {
5836
5836
my %co = @_ ;
5837
5837
5838
5838
local $/ = " \n " ;
5839
- open my $fd , " -|" , git_cmd(), ' grep' , ' -n' ,
5839
+ open my $fd , " -|" , git_cmd(), ' grep' , ' -n' , ' -z ' ,
5840
5840
$search_use_regexp ? (' -E' , ' -i' ) : ' -F' ,
5841
5841
$searchtext , $co {' tree' }
5842
5842
or die_error(500, " Open git-grep failed" );
@@ -5852,13 +5852,14 @@ sub git_search_files {
5852
5852
my $lastfile = ' ' ;
5853
5853
while (my $line = <$fd >) {
5854
5854
chomp $line ;
5855
- my ($file , $lno , $ltext , $binary );
5855
+ my ($file , $file_href , $ lno , $ltext , $binary );
5856
5856
last if ($matches ++ > 1000);
5857
5857
if ($line =~ / ^Binary file (.+) matches$ / ) {
5858
5858
$file = $1 ;
5859
5859
$binary = 1;
5860
5860
} else {
5861
- (undef , $file , $lno , $ltext ) = split (/ :/ , $line , 4);
5861
+ ($file , $lno , $ltext ) = split (/ \0 / , $line , 3);
5862
+ $file =~ s / ^$co{'tree'}:// ;
5862
5863
}
5863
5864
if ($file ne $lastfile ) {
5864
5865
$lastfile and print " </td></tr>\n " ;
@@ -5867,10 +5868,10 @@ sub git_search_files {
5867
5868
} else {
5868
5869
print " <tr class=\" light\" >\n " ;
5869
5870
}
5871
+ $file_href = href(action => " blob" , hash_base => $co {' id' },
5872
+ file_name => $file );
5870
5873
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 ));
5874
5875
print " </td><td>\n " ;
5875
5876
$lastfile = $file ;
5876
5877
}
@@ -5888,10 +5889,9 @@ sub git_search_files {
5888
5889
$ltext = esc_html($ltext , -nbsp => 1);
5889
5890
}
5890
5891
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 " ;
5895
5895
}
5896
5896
}
5897
5897
if ($lastfile ) {
0 commit comments