gitweb: Parse two-line from-file/to-file diff header in git_patchset_body
Parse two-line from-file/to-file unified diff header in git_patchset_body directly, instead of leaving pretty-printing to format_diff_line function. Hashes as from-file/to-file are replaced by proper from-file and to-file names (from $diffinfo); in the future we can put hyperlinks there. This makes possible to do blobdiff with only blobs hashes. The lines in two-line unified diff header have now class "from_file" and "to_file"; the style is chosen to match previous output (classes "rem" and "add" because of '-' and '+' as first character of patch line). 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:04 UTC
e4e4f825455f2903e4d015e51c09ec0527a0be86
2 files changed
+19
-1
gitweb/gitweb.css
+2
@@ -273,10 +273,12 @@ td.mode {
273
font-family: monospace;
274
}
275
276
+div.diff.to_file,
277
div.diff.add {
278
color: #008800;
279
}
280
281
+div.diff.from_file,
282
div.diff.rem {
283
color: #cc0000;
284
}
gitweb/gitweb.perl
+17
-1
@@ -1706,8 +1706,24 @@ sub git_patchset_body {
1706
1707
1708
if ($in_header && $patch_line =~ m/^---/) {
1709
- #print "</div>\n"
1709
+ #print "</div>\n"; # class="diff extended_header"
1710
$in_header = 0;
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";
1716
+
1717
+ $patch_line = <$fd>;
1718
+ chomp $patch_line;
1719
+
1720
+ #$patch_line =~ m/^+++/;
1721
+ $file = $diffinfo->{'to_file'};
1722
+ $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";
1725
+
1726
+ next LINE;
1727
}
1728
next LINE if $in_header;
1729