@matheusbsbs / matheus-bagliano / commits / 59e3b14e08
Fork 0

gitweb: New improved formatting of chunk header in diff

If we have provided enough info, and diff is not combined diff, and if provided diff line is chunk header, then: * split chunk header into .chunk_info and .section span elements, first containing proper chunk header, second section heading (aka. which function), for separate styling: the proper chunk header is on non-white background, section heading part uses slightly lighter color. * hyperlink from-file-range to starting line of from-file, if file was not created. * hyperlink to-file-range to starting line of to-file, if file was not deleted. Links are of invisible variety (and "list" class). Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Nov 18, 2006 at 23:35 UTC 59e3b14e08bf309baa692bf251b2cedcde131308
2 files changed +35 -1
gitweb/gitweb.css
+13
@@ -334,11 +334,13 @@ div.diff.extended_header {
334 padding: 2px 0px 2px 0px;
335 }
336
337 +div.diff a.list,
338 div.diff a.path,
339 div.diff a.hash {
340 text-decoration: none;
341 }
342
343 +div.diff a.list:hover,
344 div.diff a.path:hover,
345 div.diff a.hash:hover {
346 text-decoration: underline;
@@ -362,14 +364,25 @@ div.diff.rem {
364 color: #cc0000;
365 }
366
367 +div.diff.chunk_header a,
368 div.diff.chunk_header {
369 color: #990099;
370 +}
371
372 +div.diff.chunk_header {
373 border: dotted #ffe0ff;
374 border-width: 1px 0px 0px 0px;
375 margin-top: 2px;
376 }
377
378 +div.diff.chunk_header span.chunk_info {
379 + background-color: #ffeeff;
380 +}
381 +
382 +div.diff.chunk_header span.section {
383 + color: #aa22aa;
384 +}
385 +
386 div.diff.incomplete {
387 color: #cccccc;
388 }
gitweb/gitweb.perl
+22 -1
@@ -874,8 +874,10 @@ sub format_subject_html {
874 }
875 }
876
877 +# format patch (diff) line (rather not to be used for diff headers)
878 sub format_diff_line {
879 my $line = shift;
880 + my ($from, $to) = @_;
881 my $char = substr($line, 0, 1);
882 my $diff_class = "";
883
@@ -891,6 +893,25 @@ sub format_diff_line {
893 $diff_class = " incomplete";
894 }
895 $line = untabify($line);
896 + if ($from && $to && $line =~ m/^\@{2} /) {
897 + my ($from_text, $from_start, $from_lines, $to_text, $to_start, $to_lines, $section) =
898 + $line =~ m/^\@{2} (-(\d+)(?:,(\d+))?) (\+(\d+)(?:,(\d+))?) \@{2}(.*)$/;
899 +
900 + $from_lines = 0 unless defined $from_lines;
901 + $to_lines = 0 unless defined $to_lines;
902 +
903 + if ($from->{'href'}) {
904 + $from_text = $cgi->a({-href=>"$from->{'href'}#l$from_start",
905 + -class=>"list"}, $from_text);
906 + }
907 + if ($to->{'href'}) {
908 + $to_text = $cgi->a({-href=>"$to->{'href'}#l$to_start",
909 + -class=>"list"}, $to_text);
910 + }
911 + $line = "<span class=\"chunk_info\">@@ $from_text $to_text @@</span>" .
912 + "<span class=\"section\">" . esc_html($section, -nbsp=>1) . "</span>";
913 + return "<div class=\"diff$diff_class\">$line</div>\n";
914 + }
915 return "<div class=\"diff$diff_class\">" . esc_html($line, -nbsp=>1) . "</div>\n";
916 }
917
@@ -2372,7 +2393,7 @@ sub git_patchset_body {
2393
2394 next PATCH if ($patch_line =~ m/^diff /);
2395
2375 - print format_diff_line($patch_line);
2396 + print format_diff_line($patch_line, \%from, \%to);
2397 }
2398
2399 } continue {