{"thread":{"id":"5309","subject":"[PATCH] gitweb: bugfix: git_print_page_path() needs the hash base","startedAt":"2006-08-17T17:39:29Z","lastAt":"2006-08-17T17:39:29Z","messageCount":1,"participants":["Luben Tuikov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25493","messageId":"20060817173929.46560.qmail@web31813.mail.mud.yahoo.com","threadId":"5309","inReplyTo":null,"subject":"[PATCH] gitweb: bugfix: git_print_page_path() needs the hash base","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-08-17T17:39:29Z","receivedAt":"2006-08-17T17:39:29Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"If a file F exists in branch B, but doesn't exist\nin master branch, then blob_plain needs the hash base in\norder to properly get the file.  The hash base is passed\non symbolically so we still preserve the \"latest\" quality\nof the link presented by git_print_page_path().\n\nSigned-off-by: Luben Tuikov <ltuikov@yahoo.com>\n---\n gitweb/gitweb.perl |   22 ++++++++++++++--------\n 1 files changed, 14 insertions(+), 8 deletions(-)\n\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 36d3082..bb77b55 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1175,12 +1175,18 @@ sub git_print_header_div {\n sub git_print_page_path {\n \tmy $name = shift;\n \tmy $type = shift;\n+\tmy $hb = shift;\n \n \tif (!defined $name) {\n \t\tprint \"<div class=\\\"page_path\\\"><b>/</b></div>\\n\";\n \t} elsif (defined $type && $type eq 'blob') {\n-\t\tprint \"<div class=\\\"page_path\\\"><b>\" .\n-\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", file_name=>$file_name)}, esc_html($name)) . \"</b><br/></div>\\n\";\n+\t\tprint \"<div class=\\\"page_path\\\"><b>\";\n+\t\tif (defined $hb) {\n+\t\t\tprint $cgi->a({-href => href(action=>\"blob_plain\", hash_base=>$hb, file_name=>$file_name)}, esc_html($name));\n+\t\t} else {\n+\t\t\tprint $cgi->a({-href => href(action=>\"blob_plain\", file_name=>$file_name)}, esc_html($name));\n+\t\t}\n+\t\tprint \"</b><br/></div>\\n\";\n \t} else {\n \t\tprint \"<div class=\\\"page_path\\\"><b>\" . esc_html($name) . \"</b><br/></div>\\n\";\n \t}\n@@ -1868,7 +1874,7 @@ sub git_blame2 {\n \t\t\" | \" . $cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)}, \"head\");\n \tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n-\tgit_print_page_path($file_name, $ftype);\n+\tgit_print_page_path($file_name, $ftype, $hash_base);\n \tmy @rev_color = (qw(light2 dark2));\n \tmy $num_colors = scalar(@rev_color);\n \tmy $current_color = 0;\n@@ -1922,7 +1928,7 @@ sub git_blame {\n \t\t\" | \" . $cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)}, \"head\");\n \tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n-\tgit_print_page_path($file_name, 'blob');\n+\tgit_print_page_path($file_name, 'blob', $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n \tprint <<HTML;\n <table class=\"blame\">\n@@ -2085,7 +2091,7 @@ sub git_blob {\n \t\t      \"<br/><br/></div>\\n\" .\n \t\t      \"<div class=\\\"title\\\">$hash</div>\\n\";\n \t}\n-\tgit_print_page_path($file_name, \"blob\");\n+\tgit_print_page_path($file_name, \"blob\", $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n \tmy $nr;\n \twhile (my $line = <$fd>) {\n@@ -2135,7 +2141,7 @@ sub git_tree {\n \tif (defined $file_name) {\n \t\t$base = esc_html(\"$file_name/\");\n \t}\n-\tgit_print_page_path($file_name, 'tree');\n+\tgit_print_page_path($file_name, 'tree', $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n \tprint \"<table cellspacing=\\\"0\\\">\\n\";\n \tmy $alternate = 0;\n@@ -2332,7 +2338,7 @@ sub git_blobdiff {\n \t\t      \"<br/><br/></div>\\n\" .\n \t\t      \"<div class=\\\"title\\\">$hash vs $hash_parent</div>\\n\";\n \t}\n-\tgit_print_page_path($file_name, \"blob\");\n+\tgit_print_page_path($file_name, \"blob\", $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\" .\n \t      \"<div class=\\\"diff_info\\\">blob:\" .\n \t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash_parent, hash_base=>$hash_base, file_name=>($file_parent || $file_name))}, $hash_parent) .\n@@ -2502,7 +2508,7 @@ sub git_history {\n \tif (defined $hash) {\n \t\t$ftype = git_get_type($hash);\n \t}\n-\tgit_print_page_path($file_name, $ftype);\n+\tgit_print_page_path($file_name, $ftype, $hash_base);\n \n \topen my $fd, \"-|\",\n \t\t$GIT, \"rev-list\", \"--full-history\", $hash_base, \"--\", $file_name;\n-- \n1.4.2.gdb98\n\n"}]}