From 59fb1c944551083bbd4bccd1b5783488745f6bc4 Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Thu, 17 Aug 2006 10:39:29 -0700 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 18ba4b0d8..f7c0418c6 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1177,12 +1177,18 @@ sub git_print_header_div { sub git_print_page_path { my $name = shift; my $type = shift; + my $hb = shift; if (!defined $name) { print "
/
\n"; } elsif (defined $type && $type eq 'blob') { - print "
" . - $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name)}, esc_html($name)) . "
\n"; + print "
"; + if (defined $hb) { + print $cgi->a({-href => href(action=>"blob_plain", hash_base=>$hb, file_name=>$file_name)}, esc_html($name)); + } else { + print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name)}, esc_html($name)); + } + print "
\n"; } else { print "
" . esc_html($name) . "
\n"; } @@ -1874,7 +1880,7 @@ sub git_blame2 { " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head"); git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav); git_print_header_div('commit', esc_html($co{'title'}), $hash_base); - git_print_page_path($file_name, $ftype); + git_print_page_path($file_name, $ftype, $hash_base); my @rev_color = (qw(light2 dark2)); my $num_colors = scalar(@rev_color); my $current_color = 0; @@ -1928,7 +1934,7 @@ sub git_blame { " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head"); git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav); git_print_header_div('commit', esc_html($co{'title'}), $hash_base); - git_print_page_path($file_name, 'blob'); + git_print_page_path($file_name, 'blob', $hash_base); print "
\n"; print < @@ -2091,7 +2097,7 @@ sub git_blob { "

\n" . "
$hash
\n"; } - git_print_page_path($file_name, "blob"); + git_print_page_path($file_name, "blob", $hash_base); print "
\n"; my $nr; while (my $line = <$fd>) { @@ -2141,7 +2147,7 @@ sub git_tree { if (defined $file_name) { $base = esc_html("$file_name/"); } - git_print_page_path($file_name, 'tree'); + git_print_page_path($file_name, 'tree', $hash_base); print "
\n"; print "\n"; my $alternate = 0; @@ -2365,7 +2371,7 @@ sub git_blobdiff { "

\n" . "
$hash vs $hash_parent
\n"; } - git_print_page_path($file_name, "blob"); + git_print_page_path($file_name, "blob", $hash_base); print "
\n" . "
blob:" . $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 { if (defined $hash) { $ftype = git_get_type($hash); } - git_print_page_path($file_name, $ftype); + git_print_page_path($file_name, $ftype, $hash_base); open my $fd, "-|", $GIT, "rev-list", "--full-history", $hash_base, "--", $file_name; -- 2.30.2