From: Luben Tuikov Date: Sun, 23 Jul 2006 20:37:53 +0000 (-0700) Subject: gitweb.cgi: git_blame2: Revision blocks now have alternating colors X-Git-Tag: v1.4.2-rc3~33^2~1 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=cc1bf97e24129db2b8c4634bc733ae0a16b2beba;p=git.git gitweb.cgi: git_blame2: Revision blocks now have alternating colors A revision block is the largest number of adjacent lines of code originating from the same revision. This patch adds color to git_blame2(), in that no two adjacent revision blocks have the same color. The color alternates between light and dark. As we annotate the code lines, we alternate the color (light, dark) of code lines _per revision_. This makes it easier to see line conglomerations per revision. Signed-off-by: Luben Tuikov Signed-off-by: Junio C Hamano --- diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi index 2c2d9c8d8..16340f210 100755 --- a/gitweb/gitweb.cgi +++ b/gitweb/gitweb.cgi @@ -1295,9 +1295,11 @@ sub git_blame2 { $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n"; git_print_page_path($file_name, $ftype); - + my @rev_color = (qw(light dark)); + my $num_colors = scalar(@rev_color); + my $current_color = 0; + my $last_rev; print "
\n"; - print "\n"; print "\n"; while (my $line = <$fd>) { @@ -1307,7 +1309,13 @@ sub git_blame2 { my $lineno = $blame_line{'lineno'}; my $data = $blame_line{'data'}; - print "\n"; + if (!defined $last_rev) { + $last_rev = $full_rev; + } elsif ($last_rev ne $full_rev) { + $last_rev = $full_rev; + $current_color = ++$current_color % $num_colors; + } + print "\n"; print "\n"; print "\n"; @@ -1316,7 +1324,6 @@ sub git_blame2 { } print "
CommitLineData
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$full_rev;f=$file_name")}, esc_html($rev)) . "" . esc_html($lineno) . "
\n"; print "
"; - close $fd or print "Reading blob failed\n"; git_footer_html(); }