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

gitweb: Add invisible hyperlink to from-file/to-file diff header

Change replacing hashes as from-file/to-file with filenames from difftree to adding invisible (except underlining on hover/mouseover) hyperlink to from-file/to-file blob. /dev/null as from-file or to-file is not changed (is not hyperlinked). This makes two-file from-file/to-file unified diff header parsing in git_patchset_body more generic, and not only for legacy blobdiffs. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 25, 2006 at 21:05 UTC ef10ee877f6d4db4c9bc65d0e36b3670f0fe114e
2 files changed +20 -4
gitweb/gitweb.css
+10
@@ -273,11 +273,21 @@ td.mode {
273 font-family: monospace;
274 }
275
276 +div.diff a.list {
277 + text-decoration: none;
278 +}
279 +
280 +div.diff a.list:hover {
281 + text-decoration: underline;
282 +}
283 +
284 +div.diff.to_file a.list,
285 div.diff.to_file,
286 div.diff.add {
287 color: #008800;
288 }
289
290 +div.diff.from_file a.list,
291 div.diff.from_file,
292 div.diff.rem {
293 color: #cc0000;
gitweb/gitweb.perl
+10 -4
@@ -1711,8 +1711,11 @@ sub git_patchset_body {
1711
1712 my $file = $diffinfo->{'from_file'};
1713 $file ||= $diffinfo->{'file'};
1714 - $patch_line =~ s|a/[0-9a-fA-F]{40}|a/$file|g;
1715 - print "<div class=\"diff from_file\">" . esc_html($patch_line) . "</div>\n";
1714 + $file = $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
1715 + hash=>$diffinfo->{'from_id'}, file_name=>$file),
1716 + -class => "list"}, esc_html($file));
1717 + $patch_line =~ s|a/.*$|a/$file|g;
1718 + print "<div class=\"diff from_file\">$patch_line</div>\n";
1719
1720 $patch_line = <$fd>;
1721 chomp $patch_line;
@@ -1720,8 +1723,11 @@ sub git_patchset_body {
1723 #$patch_line =~ m/^+++/;
1724 $file = $diffinfo->{'to_file'};
1725 $file ||= $diffinfo->{'file'};
1723 - $patch_line =~ s|b/[0-9a-fA-F]{40}|b/$file|g;
1724 - print "<div class=\"diff to_file\">" . esc_html($patch_line) . "</div>\n";
1726 + $file = $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
1727 + hash=>$diffinfo->{'to_id'}, file_name=>$file),
1728 + -class => "list"}, esc_html($file));
1729 + $patch_line =~ s|b/.*|b/$file|g;
1730 + print "<div class=\"diff to_file\">$patch_line</div>\n";
1731
1732 next LINE;
1733 }