@matheusbsbs / matheus-bagliano / commits / 3a5b919cf2
Fork 0

gitweb: remove git_blame and rename git_blame2 to git_blame

git_blame is dead code. It's possible to plug it in place of git_blame2, but I don't know whether anyone does still that, because git_blame2 can now be considered stable enough, I think. Signed-off-by: Rafael Garcia-Suarez <rgarciasuarez@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rafael Garcia-Suarez committed Jun 6, 2008 at 09:53 UTC 3a5b919cf220651b681b5f036bf3bd1c61e36ef2
1 file changed +2 -99
gitweb/gitweb.perl
+2 -99
@@ -539,7 +539,7 @@ $git_dir = "$projectroot/$project" if $project;
539
540 # dispatch
541 my %actions = (
542 - "blame" => \&git_blame2,
542 + "blame" => \&git_blame,
543 "blobdiff" => \&git_blobdiff,
544 "blobdiff_plain" => \&git_blobdiff_plain,
545 "blob" => \&git_blob,
@@ -4152,7 +4152,7 @@ sub git_tag {
4152 git_footer_html();
4153 }
4154
4155 -sub git_blame2 {
4155 +sub git_blame {
4156 my $fd;
4157 my $ftype;
4158
@@ -4260,103 +4260,6 @@ HTML
4260 git_footer_html();
4261 }
4262
4263 -sub git_blame {
4264 - my $fd;
4265 -
4266 - my ($have_blame) = gitweb_check_feature('blame');
4267 - if (!$have_blame) {
4268 - die_error('403 Permission denied', "Permission denied");
4269 - }
4270 - die_error('404 Not Found', "File name not defined") if (!$file_name);
4271 - $hash_base ||= git_get_head_hash($project);
4272 - die_error(undef, "Couldn't find base commit") unless ($hash_base);
4273 - my %co = parse_commit($hash_base)
4274 - or die_error(undef, "Reading commit failed");
4275 - if (!defined $hash) {
4276 - $hash = git_get_hash_by_path($hash_base, $file_name, "blob")
4277 - or die_error(undef, "Error lookup file");
4278 - }
4279 - open ($fd, "-|", git_cmd(), "annotate", '-l', '-t', '-r', $file_name, $hash_base)
4280 - or die_error(undef, "Open git-annotate failed");
4281 - git_header_html();
4282 - my $formats_nav =
4283 - $cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
4284 - "blob") .
4285 - " | " .
4286 - $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
4287 - "history") .
4288 - " | " .
4289 - $cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
4290 - "HEAD");
4291 - git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
4292 - git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
4293 - git_print_page_path($file_name, 'blob', $hash_base);
4294 - print "<div class=\"page_body\">\n";
4295 - print <<HTML;
4296 -<table class="blame">
4297 - <tr>
4298 - <th>Commit</th>
4299 - <th>Age</th>
4300 - <th>Author</th>
4301 - <th>Line</th>
4302 - <th>Data</th>
4303 - </tr>
4304 -HTML
4305 - my @line_class = (qw(light dark));
4306 - my $line_class_len = scalar (@line_class);
4307 - my $line_class_num = $#line_class;
4308 - while (my $line = <$fd>) {
4309 - my $long_rev;
4310 - my $short_rev;
4311 - my $author;
4312 - my $time;
4313 - my $lineno;
4314 - my $data;
4315 - my $age;
4316 - my $age_str;
4317 - my $age_class;
4318 -
4319 - chomp $line;
4320 - $line_class_num = ($line_class_num + 1) % $line_class_len;
4321 -
4322 - if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
4323 - $long_rev = $1;
4324 - $author = $2;
4325 - $time = $3;
4326 - $lineno = $4;
4327 - $data = $5;
4328 - } else {
4329 - print qq( <tr><td colspan="5" class="error">Unable to parse: $line</td></tr>\n);
4330 - next;
4331 - }
4332 - $short_rev = substr ($long_rev, 0, 8);
4333 - $age = time () - $time;
4334 - $age_str = age_string ($age);
4335 - $age_str =~ s/ /&nbsp;/g;
4336 - $age_class = age_class($age);
4337 - $author = esc_html ($author);
4338 - $author =~ s/ /&nbsp;/g;
4339 -
4340 - $data = untabify($data);
4341 - $data = esc_html ($data);
4342 -
4343 - print <<HTML;
4344 - <tr class="$line_class[$line_class_num]">
4345 - <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
4346 - <td class="$age_class">$age_str</td>
4347 - <td>$author</td>
4348 - <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
4349 - <td class="pre">$data</td>
4350 - </tr>
4351 -HTML
4352 - } # while (my $line = <$fd>)
4353 - print "</table>\n\n";
4354 - close $fd
4355 - or print "Reading blob failed.\n";
4356 - print "</div>";
4357 - git_footer_html();
4358 -}
4359 -
4263 sub git_tags {
4264 my $head = git_get_head_hash($project);
4265 git_header_html();