From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 2/2] gitweb: New improved formatting of chunk header in diff
Date: Wed, 8 Nov 2006 18:00:15 +0100 [thread overview]
Message-ID: <200611081800.16001.jnareb@gmail.com> (raw)
In-Reply-To: <200611081758.57597.jnareb@gmail.com>
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>
---
gitweb/gitweb.css | 13 +++++++++++++
gitweb/gitweb.perl | 18 +++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 974b47f..7177c6e 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -334,11 +334,13 @@ div.diff.extended_header {
padding: 2px 0px 2px 0px;
}
+div.diff a.list,
div.diff a.path,
div.diff a.hash {
text-decoration: none;
}
+div.diff a.list:hover,
div.diff a.path:hover,
div.diff a.hash:hover {
text-decoration: underline;
@@ -362,14 +364,25 @@ div.diff.rem {
color: #cc0000;
}
+div.diff.chunk_header a,
div.diff.chunk_header {
color: #990099;
+}
+div.diff.chunk_header {
border: dotted #ffe0ff;
border-width: 1px 0px 0px 0px;
margin-top: 2px;
}
+div.diff.chunk_header span.chunk_info {
+ background-color: #ffeeff;
+}
+
+div.diff.chunk_header span.section {
+ color: #aa22aa;
+}
+
div.diff.incomplete {
color: #cccccc;
}
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2cf8e60..3118cb0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -873,6 +873,7 @@ sub format_subject_html {
sub format_diff_line {
my $line = shift;
+ my ($from, $to) = @_;
my $char = substr($line, 0, 1);
my $diff_class = "";
@@ -888,6 +889,21 @@ sub format_diff_line {
$diff_class = " incomplete";
}
$line = untabify($line);
+ if ($from && $to && $line =~ m/^\@{2} /) {
+ my ($from_text, $from_start, $from_lines, $to_text, $to_start, $to_lines, $section) =
+ $line =~ m/^\@{2} (-(\d+),(\d+)) (\+(\d+),(\d+)) \@{2}(.*)$/;
+ if ($from->{'href'}) {
+ $from_text = $cgi->a({-href=>"$from->{'href'}#l$from_start",
+ -class=>"list"}, $from_text);
+ }
+ if ($to->{'href'}) {
+ $to_text = $cgi->a({-href=>"$to->{'href'}#l$to_start",
+ -class=>"list"}, $to_text);
+ }
+ $line = "<span class=\"chunk_info\">@@ $from_text $to_text @@</span>" .
+ "<span class=\"section\">" . esc_html($section, -nbsp=>1) . "</span>";
+ return "<div class=\"diff$diff_class\">$line</div>\n";
+ }
return "<div class=\"diff$diff_class\">" . esc_html($line, -nbsp=>1) . "</div>\n";
}
@@ -2323,7 +2339,7 @@ sub git_patchset_body {
next LINE;
}
- print format_diff_line($patch_line);
+ print format_diff_line($patch_line, \%from, \%to);
}
print "</div>\n" if $patch_found; # class="patch"
--
1.4.3.4
next prev parent reply other threads:[~2006-11-08 16:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-08 10:47 [PATCH 0/2] Better unquoting of git quoted filenames; esc_path to escape pathnames for display Jakub Narebski
2006-11-08 10:48 ` [PATCH 1/2] gitweb: Better git-unquoting and gitweb-quoting of pathnames Jakub Narebski
2006-11-08 10:50 ` [PATCH 2/2] gitweb: Use character or octal escape codes (and add span.cntrl) in esc_path Jakub Narebski
2006-11-08 16:58 ` [PATCH 0/2] gitweb: New improved patchset view Jakub Narebski
2006-11-08 16:59 ` [PATCH 1/2] " Jakub Narebski
2006-11-08 18:27 ` Junio C Hamano
2006-11-08 18:57 ` Junio C Hamano
2006-11-08 19:04 ` Jakub Narebski
2006-11-08 18:41 ` [PATCH 1/2 (amend)] " Jakub Narebski
2006-11-08 17:00 ` Jakub Narebski [this message]
2006-11-08 20:41 ` [PATCH 2/2] gitweb: New improved formatting of chunk header in diff Junio C Hamano
2006-11-08 20:58 ` Jakub Narebski
2006-11-08 21:41 ` Junio C Hamano
2006-11-08 21:55 ` Jakub Narebski
2006-11-08 18:24 ` [PATCH 2/2] gitweb: Use character or octal escape codes (and add span.cntrl) in esc_path Junio C Hamano
2006-11-08 18:56 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200611081800.16001.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).