@matheusbsbs / matheus-bagliano / commits / cc1bf97e24
Fork 0

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 <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Luben Tuikov committed Jul 23, 2006 at 13:37 UTC cc1bf97e24129db2b8c4634bc733ae0a16b2beba
1 file changed +11 -4
gitweb/gitweb.cgi
+11 -4
@@ -1295,9 +1295,11 @@ sub git_blame2 {
1295 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1296 "</div>\n";
1297 git_print_page_path($file_name, $ftype);
1298 -
1298 + my @rev_color = (qw(light dark));
1299 + my $num_colors = scalar(@rev_color);
1300 + my $current_color = 0;
1301 + my $last_rev;
1302 print "<div class=\"page_body\">\n";
1300 -
1303 print "<table class=\"blame\">\n";
1304 print "<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\n";
1305 while (my $line = <$fd>) {
@@ -1307,7 +1309,13 @@ sub git_blame2 {
1309 my $lineno = $blame_line{'lineno'};
1310 my $data = $blame_line{'data'};
1311
1310 - print "<tr>\n";
1312 + if (!defined $last_rev) {
1313 + $last_rev = $full_rev;
1314 + } elsif ($last_rev ne $full_rev) {
1315 + $last_rev = $full_rev;
1316 + $current_color = ++$current_color % $num_colors;
1317 + }
1318 + print "<tr class=\"$rev_color[$current_color]\">\n";
1319 print "<td class=\"sha1\">" .
1320 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$full_rev;f=$file_name")}, esc_html($rev)) . "</td>\n";
1321 print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" . esc_html($lineno) . "</a></td>\n";
@@ -1316,7 +1324,6 @@ sub git_blame2 {
1324 }
1325 print "</table>\n";
1326 print "</div>";
1319 -
1327 close $fd or print "Reading blob failed\n";
1328 git_footer_html();
1329 }