git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame
@ 2008-06-06  7:53 Rafael Garcia-Suarez
  2008-06-06  8:24 ` Jakub Narebski
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael Garcia-Suarez @ 2008-06-06  7:53 UTC (permalink / raw)
  To: git; +Cc: Rafael Garcia-Suarez

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>
---
 gitweb/gitweb.perl |  101 +--------------------------------------------------
 1 files changed, 2 insertions(+), 99 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 198772c..8d1f3e0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -539,7 +539,7 @@ $git_dir = "$projectroot/$project" if $project;
 
 # dispatch
 my %actions = (
-	"blame" => \&git_blame2,
+	"blame" => \&git_blame,
 	"blobdiff" => \&git_blobdiff,
 	"blobdiff_plain" => \&git_blobdiff_plain,
 	"blob" => \&git_blob,
@@ -4152,7 +4152,7 @@ sub git_tag {
 	git_footer_html();
 }
 
-sub git_blame2 {
+sub git_blame {
 	my $fd;
 	my $ftype;
 
@@ -4260,103 +4260,6 @@ HTML
 	git_footer_html();
 }
 
-sub git_blame {
-	my $fd;
-
-	my ($have_blame) = gitweb_check_feature('blame');
-	if (!$have_blame) {
-		die_error('403 Permission denied', "Permission denied");
-	}
-	die_error('404 Not Found', "File name not defined") if (!$file_name);
-	$hash_base ||= git_get_head_hash($project);
-	die_error(undef, "Couldn't find base commit") unless ($hash_base);
-	my %co = parse_commit($hash_base)
-		or die_error(undef, "Reading commit failed");
-	if (!defined $hash) {
-		$hash = git_get_hash_by_path($hash_base, $file_name, "blob")
-			or die_error(undef, "Error lookup file");
-	}
-	open ($fd, "-|", git_cmd(), "annotate", '-l', '-t', '-r', $file_name, $hash_base)
-		or die_error(undef, "Open git-annotate failed");
-	git_header_html();
-	my $formats_nav =
-		$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
-		        "blob") .
-		" | " .
-		$cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
-			"history") .
-		" | " .
-		$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', $hash_base);
-	print "<div class=\"page_body\">\n";
-	print <<HTML;
-<table class="blame">
-  <tr>
-    <th>Commit</th>
-    <th>Age</th>
-    <th>Author</th>
-    <th>Line</th>
-    <th>Data</th>
-  </tr>
-HTML
-	my @line_class = (qw(light dark));
-	my $line_class_len = scalar (@line_class);
-	my $line_class_num = $#line_class;
-	while (my $line = <$fd>) {
-		my $long_rev;
-		my $short_rev;
-		my $author;
-		my $time;
-		my $lineno;
-		my $data;
-		my $age;
-		my $age_str;
-		my $age_class;
-
-		chomp $line;
-		$line_class_num = ($line_class_num + 1) % $line_class_len;
-
-		if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
-			$long_rev = $1;
-			$author   = $2;
-			$time     = $3;
-			$lineno   = $4;
-			$data     = $5;
-		} else {
-			print qq(  <tr><td colspan="5" class="error">Unable to parse: $line</td></tr>\n);
-			next;
-		}
-		$short_rev  = substr ($long_rev, 0, 8);
-		$age        = time () - $time;
-		$age_str    = age_string ($age);
-		$age_str    =~ s/ /&nbsp;/g;
-		$age_class  = age_class($age);
-		$author     = esc_html ($author);
-		$author     =~ s/ /&nbsp;/g;
-
-		$data = untabify($data);
-		$data = esc_html ($data);
-
-		print <<HTML;
-  <tr class="$line_class[$line_class_num]">
-    <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
-    <td class="$age_class">$age_str</td>
-    <td>$author</td>
-    <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
-    <td class="pre">$data</td>
-  </tr>
-HTML
-	} # while (my $line = <$fd>)
-	print "</table>\n\n";
-	close $fd
-		or print "Reading blob failed.\n";
-	print "</div>";
-	git_footer_html();
-}
-
 sub git_tags {
 	my $head = git_get_head_hash($project);
 	git_header_html();
-- 
1.5.6.rc1.5.gadf6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame
  2008-06-06  7:53 [PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame Rafael Garcia-Suarez
@ 2008-06-06  8:24 ` Jakub Narebski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Narebski @ 2008-06-06  8:24 UTC (permalink / raw)
  To: Rafael Garcia-Suarez; +Cc: git

Rafael Garcia-Suarez <rgarciasuarez@gmail.com> writes:

> 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.

First, the two competing subroutines, git_blame and git_blame2
are from the time when there were two competing 'blame'
implementations, respectively git-annotate (in Perl) and git-blame.  
git-blame won, and nowadays git-annotate is builtin alias passing
'-c' option (Use the same output mode as git-annotate) to git-blame.

git_blame and git_blame2 had not only different backend, but have
different output as well.  git_blame uses more columns, showing more
info at first glance, while git_blame2 is simpler and less cluttered.

That said, removing git_blame is a good idea (there was even some
patch on this mailing list doing that, but IIRC it was part of larger
series, and somehow got dropped, at least for mainline gitweb).  There
is always history if we want to check how its output looked like.

Acked-by: Jakub Narebski <jnareb@gmail.com>

(FWIW, as I am not gitweb maintainer).
-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-06  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-06  7:53 [PATCH] gitweb: remove git_blame and rename git_blame2 to git_blame Rafael Garcia-Suarez
2008-06-06  8:24 ` Jakub Narebski

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).