{"thread":{"id":"4965","subject":"[PATCH 3/3] gitweb.cgi: git_blame2: Revision blocks now have alternating colors","startedAt":"2006-07-23T20:37:53Z","lastAt":"2006-07-23T20:37:53Z","messageCount":1,"participants":["Luben Tuikov"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"24027","messageId":"20060723203753.60963.qmail@web31814.mail.mud.yahoo.com","threadId":"4965","inReplyTo":null,"subject":"[PATCH 3/3] gitweb.cgi: git_blame2: Revision blocks now have alternating colors","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-07-23T20:37:53Z","receivedAt":"2006-07-23T20:37:53Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"A revision block is the largest number of adjacent\nlines of code originating from the same revision.\n\nThis patch adds color to git_blame2(), in that no two\nadjacent revision blocks have the same color.  The color\nalternates between light and dark.\n\nAs we annotate the code lines, we alternate the color\n(light, dark) of code lines _per revision_.  This makes it\neasier to see line conglomerations per revision.\n\nSigned-off-by: Luben Tuikov <ltuikov@yahoo.com>\n---\n gitweb/gitweb.cgi |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi\nindex 2c2d9c8..16340f2 100755\n--- a/gitweb/gitweb.cgi\n+++ b/gitweb/gitweb.cgi\n@@ -1295,9 +1295,11 @@ sub git_blame2 {\n \t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$hash_base\"), -class => \"title\"}, esc_html($co{'title'})) .\n \t\t\"</div>\\n\";\n \tgit_print_page_path($file_name, $ftype);\n-\n+\tmy @rev_color = (qw(light dark));\n+\tmy $num_colors = scalar(@rev_color);\n+\tmy $current_color = 0;\n+\tmy $last_rev;\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n-\n \tprint \"<table class=\\\"blame\\\">\\n\";\n \tprint \"<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\\n\";\n \twhile (my $line = <$fd>) {\n@@ -1307,7 +1309,13 @@ sub git_blame2 {\n \t\tmy $lineno = $blame_line{'lineno'};\n \t\tmy $data = $blame_line{'data'};\n \n-\t\tprint \"<tr>\\n\";\n+\t\tif (!defined $last_rev) {\n+\t\t\t$last_rev = $full_rev;\n+\t\t} elsif ($last_rev ne $full_rev) {\n+\t\t\t$last_rev = $full_rev;\n+\t\t\t$current_color = ++$current_color % $num_colors;\n+\t\t}\n+\t\tprint \"<tr class=\\\"$rev_color[$current_color]\\\">\\n\";\n \t\tprint \"<td class=\\\"sha1\\\">\" .\n \t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$full_rev;f=$file_name\")}, esc_html($rev)) . \"</td>\\n\";\n \t\tprint \"<td class=\\\"linenr\\\"><a id=\\\"l$lineno\\\" href=\\\"#l$lineno\\\" class=\\\"linenr\\\">\" . esc_html($lineno) . \"</a></td>\\n\";\n@@ -1316,8 +1324,6 @@ sub git_blame2 {\n \t}\n \tprint \"</table>\\n\";\n \tprint \"</div>\";\n-\n \tclose $fd or print \"Reading blob failed\\n\";\n \tgit_footer_html();\n }\n-- \n1.4.2.rc1.g9b54\n\n"}]}