gitweb: bugfix: git_print_page_path() needs the hash base
If a file F exists in branch B, but doesn't exist in master branch, then blob_plain needs the hash base in order to properly get the file. The hash base is passed on symbolically so we still preserve the "latest" quality of the link presented by git_print_page_path(). Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Luben Tuikov committed
Aug 17, 2006 at 10:39 UTC
59fb1c944551083bbd4bccd1b5783488745f6bc4
1 file changed
+14
-8
gitweb/gitweb.perl
+14
-8
@@ -1177,12 +1177,18 @@ sub git_print_header_div {
1177
sub git_print_page_path {
1178
my $name = shift;
1179
my $type = shift;
1180
+ my $hb = shift;
1181
1182
if (!defined $name) {
1183
print "<div class=\"page_path\"><b>/</b></div>\n";
1184
} elsif (defined $type && $type eq 'blob') {
1184
- print "<div class=\"page_path\"><b>" .
1185
- $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name)}, esc_html($name)) . "</b><br/></div>\n";
1185
+ print "<div class=\"page_path\"><b>";
1186
+ if (defined $hb) {
1187
+ print $cgi->a({-href => href(action=>"blob_plain", hash_base=>$hb, file_name=>$file_name)}, esc_html($name));
1188
+ } else {
1189
+ print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name)}, esc_html($name));
1190
+ }
1191
+ print "</b><br/></div>\n";
1192
} else {
1193
print "<div class=\"page_path\"><b>" . esc_html($name) . "</b><br/></div>\n";
1194
}
@@ -1874,7 +1880,7 @@ sub git_blame2 {
1880
" | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head");
1881
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1882
git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1877
- git_print_page_path($file_name, $ftype);
1883
+ git_print_page_path($file_name, $ftype, $hash_base);
1884
my @rev_color = (qw(light2 dark2));
1885
my $num_colors = scalar(@rev_color);
1886
my $current_color = 0;
@@ -1928,7 +1934,7 @@ sub git_blame {
1934
" | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head");
1935
git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1936
git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1931
- git_print_page_path($file_name, 'blob');
1937
+ git_print_page_path($file_name, 'blob', $hash_base);
1938
print "<div class=\"page_body\">\n";
1939
print <<HTML;
1940
<table class="blame">
@@ -2091,7 +2097,7 @@ sub git_blob {
2097
"<br/><br/></div>\n" .
2098
"<div class=\"title\">$hash</div>\n";
2099
}
2094
- git_print_page_path($file_name, "blob");
2100
+ git_print_page_path($file_name, "blob", $hash_base);
2101
print "<div class=\"page_body\">\n";
2102
my $nr;
2103
while (my $line = <$fd>) {
@@ -2141,7 +2147,7 @@ sub git_tree {
2147
if (defined $file_name) {
2148
$base = esc_html("$file_name/");
2149
}
2144
- git_print_page_path($file_name, 'tree');
2150
+ git_print_page_path($file_name, 'tree', $hash_base);
2151
print "<div class=\"page_body\">\n";
2152
print "<table cellspacing=\"0\">\n";
2153
my $alternate = 0;
@@ -2365,7 +2371,7 @@ sub git_blobdiff {
2371
"<br/><br/></div>\n" .
2372
"<div class=\"title\">$hash vs $hash_parent</div>\n";
2373
}
2368
- git_print_page_path($file_name, "blob");
2374
+ git_print_page_path($file_name, "blob", $hash_base);
2375
print "<div class=\"page_body\">\n" .
2376
"<div class=\"diff_info\">blob:" .
2377
$cgi->a({-href => href(action=>"blob", hash=>$hash_parent, hash_base=>$hash_base, file_name=>($file_parent || $file_name))}, $hash_parent) .
@@ -2535,7 +2541,7 @@ sub git_history {
2541
if (defined $hash) {
2542
$ftype = git_get_type($hash);
2543
}
2538
- git_print_page_path($file_name, $ftype);
2544
+ git_print_page_path($file_name, $ftype, $hash_base);
2545
2546
open my $fd, "-|",
2547
$GIT, "rev-list", "--full-history", $hash_base, "--", $file_name;