{"thread":{"id":"5711","subject":"[PATCH] gitweb: extend blame to show links to diff and previous","startedAt":"2006-09-26T23:45:31Z","lastAt":"2006-09-26T23:45:31Z","messageCount":1,"participants":["Luben Tuikov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27723","messageId":"20060926234531.26684.qmail@web31803.mail.mud.yahoo.com","threadId":"5711","inReplyTo":null,"subject":"[PATCH] gitweb: extend blame to show links to diff and previous","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-09-26T23:45:31Z","receivedAt":"2006-09-26T23:45:31Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"git_blame2() now has two more columns, \"Prev\" and \"Diff\",\nbefore the \"Commit\" column, as follows:\n\nPrev\tDiff\tCommit\tLine\tData\nSHA     Diff    SHA        N    ...\n...\n\nThe \"Prev\" column shows the SHA of the parent commit,\nbetween which this line changed.  Clicking on it shows the\nblame of the file as of the parent commit, for that line.\n\nSo clicking repeatedly on \"Prev\" would show you the blame\nof that file, from the point of view of the changes\nof that particular line whose \"Prev\" you're clicking on.\n\nThe \"Diff\" column shows \"Diff\" which is a link to blobdiff\nbetween \"Prev\" and \"Commit\" commits _for that line_.\n\nSo clicking on \"Diff\" would show you the blobdiff (HTML)\nbetween the parent commit and this commit which changed\nthat particular line.\n\nSigned-off-by: Luben Tuikov <ltuikov@yahoo.com>\n---\n gitweb/gitweb.perl |   18 +++++++++++++++++-\n 1 files changed, 17 insertions(+), 1 deletions(-)\n\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 56638f2..d2519f0 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2439,7 +2439,7 @@ sub git_blame2 {\n \tprint <<HTML;\n <div class=\"page_body\">\n <table class=\"blame\">\n-<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\n+<tr><th>Prev</th><th>Diff</th><th>Commit</th><th>Line</th><th>Data</th></tr>\n HTML\n \twhile (<$fd>) {\n \t\t/^([0-9a-fA-F]{40}).*?(\\d+)\\)\\s{1}(\\s*.*)/;\n@@ -2447,6 +2447,8 @@ HTML\n \t\tmy $rev = substr($full_rev, 0, 8);\n \t\tmy $lineno = $2;\n \t\tmy $data = $3;\n+\t\tmy %pco = parse_commit($full_rev);\n+\t\tmy $parent = $pco{'parent'};\n \n \t\tif (!defined $last_rev) {\n \t\t\t$last_rev = $full_rev;\n@@ -2455,11 +2457,25 @@ HTML\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\t# Print the Prev link\n+\t\tprint \"<td class=\\\"sha1\\\">\";\n+\t\tprint $cgi->a({-href => href(action=>\"blame\", hash_base=>$parent, file_name=>$file_name)},\n+\t\t\t      esc_html(substr($parent, 0, 8)));\n+\t\tprint \"</td>\\n\";\n+\t\t# Print the Diff (blobdiff) link\n+\t\tprint \"<td>\";\n+\t\tprint $cgi->a({-href => href(action=>\"blobdiff\", file_name=>$file_name, hash_parent_base=>$parent,\n+\t\t\t\t\t     hash_base=>$full_rev)},\n+\t\t\t      esc_html(\"Diff\"));\n+\t\tprint \"</td>\\n\";\n+\t\t# Print the Commit link\n \t\tprint \"<td class=\\\"sha1\\\">\" .\n \t\t\t$cgi->a({-href => href(action=>\"commit\", hash=>$full_rev, file_name=>$file_name)},\n \t\t\t        esc_html($rev)) . \"</td>\\n\";\n+\t\t# Print the Line number\n \t\tprint \"<td class=\\\"linenr\\\"><a id=\\\"l$lineno\\\" href=\\\"#l$lineno\\\" class=\\\"linenr\\\">\" .\n \t\t      esc_html($lineno) . \"</a></td>\\n\";\n+\t\t# Print the Data\n \t\tprint \"<td class=\\\"pre\\\">\" . esc_html($data) . \"</td>\\n\";\n \t\tprint \"</tr>\\n\";\n \t}\n-- \n1.4.2.1.g03d06\n"}]}