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>
This commit is contained in:
Jakub Narebski 2006-08-25 21:05:07 +02:00 committed by Junio C Hamano
parent e4e4f82545
commit ef10ee877f
2 changed files with 20 additions and 4 deletions

View File

@ -273,11 +273,21 @@ td.mode {
font-family: monospace; font-family: monospace;
} }
div.diff a.list {
text-decoration: none;
}
div.diff a.list:hover {
text-decoration: underline;
}
div.diff.to_file a.list,
div.diff.to_file, div.diff.to_file,
div.diff.add { div.diff.add {
color: #008800; color: #008800;
} }
div.diff.from_file a.list,
div.diff.from_file, div.diff.from_file,
div.diff.rem { div.diff.rem {
color: #cc0000; color: #cc0000;

View File

@ -1711,8 +1711,11 @@ sub git_patchset_body {
my $file = $diffinfo->{'from_file'}; my $file = $diffinfo->{'from_file'};
$file ||= $diffinfo->{'file'}; $file ||= $diffinfo->{'file'};
$patch_line =~ s|a/[0-9a-fA-F]{40}|a/$file|g; $file = $cgi->a({-href => href(action=>"blob", hash_base=>$hash_parent,
print "<div class=\"diff from_file\">" . esc_html($patch_line) . "</div>\n"; hash=>$diffinfo->{'from_id'}, file_name=>$file),
-class => "list"}, esc_html($file));
$patch_line =~ s|a/.*$|a/$file|g;
print "<div class=\"diff from_file\">$patch_line</div>\n";
$patch_line = <$fd>; $patch_line = <$fd>;
chomp $patch_line; chomp $patch_line;
@ -1720,8 +1723,11 @@ sub git_patchset_body {
#$patch_line =~ m/^+++/; #$patch_line =~ m/^+++/;
$file = $diffinfo->{'to_file'}; $file = $diffinfo->{'to_file'};
$file ||= $diffinfo->{'file'}; $file ||= $diffinfo->{'file'};
$patch_line =~ s|b/[0-9a-fA-F]{40}|b/$file|g; $file = $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
print "<div class=\"diff to_file\">" . esc_html($patch_line) . "</div>\n"; hash=>$diffinfo->{'to_id'}, file_name=>$file),
-class => "list"}, esc_html($file));
$patch_line =~ s|b/.*|b/$file|g;
print "<div class=\"diff to_file\">$patch_line</div>\n";
next LINE; next LINE;
} }