{"thread":{"id":"8207","subject":"[PATCH] gitweb: Remove git_blame (superseded by git_blame2)","startedAt":"2007-05-18T19:22:53Z","lastAt":"2007-05-18T19:22:53Z","messageCount":1,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"42510","messageId":"20070518192252.20855.92056.stgit@rover","threadId":"8207","inReplyTo":null,"subject":"[PATCH] gitweb: Remove git_blame (superseded by git_blame2)","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-05-18T19:22:53Z","receivedAt":"2007-05-18T19:22:53Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"This patch definitely removes git_blame() from the source and renames\ngit_blame2() to git_blame(); it was already the default handler for the\nblame action for a long time and it has been actually broken for some time\nnow (I'm not sure how long), so noone probably cares about it much (I have\nan alternative trivial patch to fix it too). All the information listing is\nalready included in git_blame2() output now.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n gitweb/gitweb.perl |  101 +---------------------------------------------------\n 1 files changed, 2 insertions(+), 99 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 2dc7be8..f67ba22 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -473,7 +473,7 @@ $git_dir = \"$projectroot/$project\" if $project;\n \n # dispatch\n my %actions = (\n-\t\"blame\" => \\&git_blame2,\n+\t\"blame\" => \\&git_blame,\n \t\"blame_incremental\" => \\&git_blame_incremental,\n \t\"blame_data\" => \\&git_blame_data,\n \t\"blobdiff\" => \\&git_blobdiff,\n@@ -3704,7 +3704,7 @@ HTML\n }\n \n \n-sub git_blame2 {\n+sub git_blame {\n \tmy $fd;\n \tmy $ftype;\n \n@@ -3820,103 +3820,6 @@ HTML\n \tgit_footer_html();\n }\n \n-sub git_blame {\n-\tmy $fd;\n-\n-\tmy ($have_blame) = gitweb_check_feature('blame');\n-\tif (!$have_blame) {\n-\t\tdie_error('403 Permission denied', \"Permission denied\");\n-\t}\n-\tdie_error('404 Not Found', \"File name not defined\") if (!$file_name);\n-\t$hash_base ||= git_get_head_hash($project);\n-\tdie_error(undef, \"Couldn't find base commit\") unless ($hash_base);\n-\tmy %co = parse_commit($hash_base)\n-\t\tor die_error(undef, \"Reading commit failed\");\n-\tif (!defined $hash) {\n-\t\t$hash = git_get_hash_by_path($hash_base, $file_name, \"blob\")\n-\t\t\tor die_error(undef, \"Error lookup file\");\n-\t}\n-\topen ($fd, \"-|\", git_cmd(), \"annotate\", '-l', '-t', '-r', $file_name, $hash_base)\n-\t\tor die_error(undef, \"Open git-annotate failed\");\n-\tgit_header_html();\n-\tmy $formats_nav =\n-\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},\n-\t\t        \"blob\") .\n-\t\t\" | \" .\n-\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},\n-\t\t\t\"history\") .\n-\t\t\" | \" .\n-\t\t$cgi->a({-href => href(action=>\"blame\", file_name=>$file_name), -class => \"blamelink\"},\n-\t\t        \"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', $hash_base);\n-\tprint \"<div class=\\\"page_body\\\">\\n\";\n-\tprint <<HTML;\n-<table class=\"blame\">\n-  <tr>\n-    <th>Commit</th>\n-    <th>Age</th>\n-    <th>Author</th>\n-    <th>Line</th>\n-    <th>Data</th>\n-  </tr>\n-HTML\n-\tmy @line_class = (qw(light dark));\n-\tmy $line_class_len = scalar (@line_class);\n-\tmy $line_class_num = $#line_class;\n-\twhile (my $line = <$fd>) {\n-\t\tmy $long_rev;\n-\t\tmy $short_rev;\n-\t\tmy $author;\n-\t\tmy $time;\n-\t\tmy $lineno;\n-\t\tmy $data;\n-\t\tmy $age;\n-\t\tmy $age_str;\n-\t\tmy $age_class;\n-\n-\t\tchomp $line;\n-\t\t$line_class_num = ($line_class_num + 1) % $line_class_len;\n-\n-\t\tif ($line =~ m/^([0-9a-fA-F]{40})\\t\\(\\s*([^\\t]+)\\t(\\d+) [+-]\\d\\d\\d\\d\\t(\\d+)\\)(.*)$/) {\n-\t\t\t$long_rev = $1;\n-\t\t\t$author   = $2;\n-\t\t\t$time     = $3;\n-\t\t\t$lineno   = $4;\n-\t\t\t$data     = $5;\n-\t\t} else {\n-\t\t\tprint qq(  <tr><td colspan=\"5\" class=\"error\">Unable to parse: $line</td></tr>\\n);\n-\t\t\tnext;\n-\t\t}\n-\t\t$short_rev  = substr ($long_rev, 0, 8);\n-\t\t$age        = time () - $time;\n-\t\t$age_str    = age_string ($age);\n-\t\t$age_str    =~ s/ /&nbsp;/g;\n-\t\t$age_class  = age_class($age);\n-\t\t$author     = esc_html ($author);\n-\t\t$author     =~ s/ /&nbsp;/g;\n-\n-\t\t$data = untabify($data);\n-\t\t$data = esc_html ($data);\n-\n-\t\tprint <<HTML;\n-  <tr class=\"$line_class[$line_class_num]\">\n-    <td class=\"sha1\"><a href=\"${\\href (action=>\"commit\", hash=>$long_rev)}\" class=\"text\">$short_rev..</a></td>\n-    <td class=\"$age_class\">$age_str</td>\n-    <td>$author</td>\n-    <td class=\"linenr\"><a id=\"$lineno\" href=\"#$lineno\" class=\"linenr\">$lineno</a></td>\n-    <td class=\"pre\">$data</td>\n-  </tr>\n-HTML\n-\t} # while (my $line = <$fd>)\n-\tprint \"</table>\\n\\n\";\n-\tclose $fd\n-\t\tor print \"Reading blob failed.\\n\";\n-\tprint \"</div>\";\n-\tgit_footer_html();\n-}\n-\n sub git_tags {\n \tmy $head = git_get_head_hash($project);\n \tgit_header_html();\n"}]}