@matheusbsbs / matheus-bagliano / commits / 65910395c0
Fork 0

gitweb: extend blame to show links to diff and previous

git_blame2() now has two more columns, "Prev" and "Diff", before the "Commit" column, as follows: Prev Diff Commit Line Data SHA Diff SHA N ... ... The "Prev" column shows the SHA of the parent commit, between which this line changed. Clicking on it shows the blame of the file as of the parent commit, for that line. So clicking repeatedly on "Prev" would show you the blame of that file, from the point of view of the changes of that particular line whose "Prev" you're clicking on. The "Diff" column shows "Diff" which is a link to blobdiff between "Prev" and "Commit" commits _for that line_. So clicking on "Diff" would show you the blobdiff (HTML) between the parent commit and this commit which changed that particular line. Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Luben Tuikov committed Sep 26, 2006 at 16:45 UTC 65910395c08e3dc4be685a9a9f60adfa61c89aa5
1 file changed +17 -1
gitweb/gitweb.perl
+17 -1
@@ -2439,7 +2439,7 @@ sub git_blame2 {
2439 print <<HTML;
2440 <div class="page_body">
2441 <table class="blame">
2442 -<tr><th>Commit</th><th>Line</th><th>Data</th></tr>
2442 +<tr><th>Prev</th><th>Diff</th><th>Commit</th><th>Line</th><th>Data</th></tr>
2443 HTML
2444 while (<$fd>) {
2445 /^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
@@ -2447,6 +2447,8 @@ HTML
2447 my $rev = substr($full_rev, 0, 8);
2448 my $lineno = $2;
2449 my $data = $3;
2450 + my %pco = parse_commit($full_rev);
2451 + my $parent = $pco{'parent'};
2452
2453 if (!defined $last_rev) {
2454 $last_rev = $full_rev;
@@ -2455,11 +2457,25 @@ HTML
2457 $current_color = ++$current_color % $num_colors;
2458 }
2459 print "<tr class=\"$rev_color[$current_color]\">\n";
2460 + # Print the Prev link
2461 + print "<td class=\"sha1\">";
2462 + print $cgi->a({-href => href(action=>"blame", hash_base=>$parent, file_name=>$file_name)},
2463 + esc_html(substr($parent, 0, 8)));
2464 + print "</td>\n";
2465 + # Print the Diff (blobdiff) link
2466 + print "<td>";
2467 + print $cgi->a({-href => href(action=>"blobdiff", file_name=>$file_name, hash_parent_base=>$parent,
2468 + hash_base=>$full_rev)},
2469 + esc_html("Diff"));
2470 + print "</td>\n";
2471 + # Print the Commit link
2472 print "<td class=\"sha1\">" .
2473 $cgi->a({-href => href(action=>"commit", hash=>$full_rev, file_name=>$file_name)},
2474 esc_html($rev)) . "</td>\n";
2475 + # Print the Line number
2476 print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" .
2477 esc_html($lineno) . "</a></td>\n";
2478 + # Print the Data
2479 print "<td class=\"pre\">" . esc_html($data) . "</td>\n";
2480 print "</tr>\n";
2481 }