Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
gitweb: Fix file links in "grep" search
author
Jakub Narebski
<jnareb@gmail.com>
Thu, 5 Jan 2012 20:26:48 +0000
(21:26 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 5 Jan 2012 21:29:50 +0000
(13:29 -0800)
There were two bugs in generating file links (links to "blob" view),
one hidden by the other. The correct way of generating file link is
href(action=>"blob", hash_base=>$co{'id'},
file_name=>$file);
It was $co{'hash'} (this key does not exist, and therefore this is
undef), and 'hash' instead of 'hash_base'.
To have this fix applied in single place, this commit also reduces
code duplication by saving file link (which is used for line links) in
$file_href.
Reported-by: Thomas Perl <th.perl@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
1327d83
)
diff --git
a/gitweb/gitweb.perl
b/gitweb/gitweb.perl
index 4f0c3bd90c7f90dad1674f50999da534c33c0261..1d2f046736062b83fa63e349964232e8f665b6f8 100755
(executable)
--- a/
gitweb/gitweb.perl
+++ b/
gitweb/gitweb.perl
@@
-5715,7
+5715,7
@@
sub git_search_files {
my $lastfile = '';
while (my $line = <$fd>) {
chomp $line;
my $lastfile = '';
while (my $line = <$fd>) {
chomp $line;
- my ($file, $lno, $ltext, $binary);
+ my ($file, $
file_href, $
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;
@@
-5730,10
+5730,10
@@
sub git_search_files {
} else {
print "<tr class=\"light\">\n";
}
} else {
print "<tr class=\"light\">\n";
}
+ $file_href = href(action=>"blob", hash_base=>$co{'id'},
+ file_name=>$file);
print "<td class=\"list\">".
print "<td class=\"list\">".
- $cgi->a({-href => href(action=>"blob", hash=>$co{'hash'},
- file_name=>"$file"),
- -class => "list"}, esc_path($file));
+ $cgi->a({-href => $file_href, -class => "list"}, esc_path($file));
print "</td><td>\n";
$lastfile = $file;
}
print "</td><td>\n";
$lastfile = $file;
}
@@
-5751,10
+5751,9
@@
sub git_search_files {
$ltext = esc_html($ltext, -nbsp=>1);
}
print "<div class=\"pre\">" .
$ltext = esc_html($ltext, -nbsp=>1);
}
print "<div class=\"pre\">" .
- $cgi->a({-href => href(action=>"blob", hash=>$co{'hash'},
- file_name=>"$file").'#l'.$lno,
- -class => "linenr"}, sprintf('%4i', $lno))
- . ' ' . $ltext . "</div>\n";
+ $cgi->a({-href => $file_href.'#l'.$lno,
+ -class => "linenr"}, sprintf('%4i', $lno)) .
+ ' ' . $ltext . "</div>\n";
}
}
if ($lastfile) {
}
}
if ($lastfile) {