{"thread":{"id":"13827","subject":"[PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame","startedAt":"2008-06-06T07:53:32Z","lastAt":"2008-06-06T08:24:37Z","messageCount":2,"participants":["Rafael Garcia-Suarez","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"78877","messageId":"1212738812-31277-1-git-send-email-rgarciasuarez@gmail.com","threadId":"13827","inReplyTo":null,"subject":"[PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame","fromName":"Rafael Garcia-Suarez","fromEmail":"rgarciasuarez@gmail.com","sentAt":"2008-06-06T07:53:32Z","receivedAt":"2008-06-06T07:53:32Z","isPatch":true,"sender":{"key":"rgarciasuarez@gmail.com","avatar":null},"body":"git_blame is dead code. It's possible to plug it in place of\ngit_blame2, but I don't know whether anyone does still that,\nbecause git_blame2 can now be considered stable enough, I think.\n\nSigned-off-by: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>\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 198772c..8d1f3e0 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -539,7 +539,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\"blobdiff\" => \\&git_blobdiff,\n \t\"blobdiff_plain\" => \\&git_blobdiff_plain,\n \t\"blob\" => \\&git_blob,\n@@ -4152,7 +4152,7 @@ sub git_tag {\n \tgit_footer_html();\n }\n \n-sub git_blame2 {\n+sub git_blame {\n \tmy $fd;\n \tmy $ftype;\n \n@@ -4260,103 +4260,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)},\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-- \n1.5.6.rc1.5.gadf6\n"},{"id":"78879","messageId":"m3wsl3x96p.fsf@localhost.localdomain","threadId":"13827","inReplyTo":"1212738812-31277-1-git-send-email-rgarciasuarez@gmail.com","subject":"Re: [PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-06T08:24:37Z","receivedAt":"2008-06-06T08:24:37Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Rafael Garcia-Suarez <rgarciasuarez@gmail.com> writes:\n\n> git_blame is dead code. It's possible to plug it in place of\n> git_blame2, but I don't know whether anyone does still that,\n> because git_blame2 can now be considered stable enough, I think.\n\nFirst, the two competing subroutines, git_blame and git_blame2\nare from the time when there were two competing 'blame'\nimplementations, respectively git-annotate (in Perl) and git-blame.  \ngit-blame won, and nowadays git-annotate is builtin alias passing\n'-c' option (Use the same output mode as git-annotate) to git-blame.\n\ngit_blame and git_blame2 had not only different backend, but have\ndifferent output as well.  git_blame uses more columns, showing more\ninfo at first glance, while git_blame2 is simpler and less cluttered.\n\nThat said, removing git_blame is a good idea (there was even some\npatch on this mailing list doing that, but IIRC it was part of larger\nseries, and somehow got dropped, at least for mainline gitweb).  There\nis always history if we want to check how its output looked like.\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n(FWIW, as I am not gitweb maintainer).\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}