* [PATCH 0/8] www: diff viewing enhancements
@ 2022-08-23 8:31 7% Eric Wong
2022-08-23 8:31 7% ` [PATCH 2/8] viewdiff: linkify diffstats for non-format-patch emails Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2022-08-23 8:31 UTC (permalink / raw)
To: meta
1/8 is another step towards making df*: prefixes more visible
and useful to users. It took me a loong while to arrive at the
current UI + behaviors and I'm still not 100% sure it's ideal or
if it would bloat pages too much...
2/8 is something I noticed while scanning through LKML to ensure
1/8 was working reasonably well. Another step towards bigger,
and scarier regexps :P But it's less code!
3/8 is from me having second thoughts on patchids...
4/8 makes navigation easier and something I've wanted for a while
5/8 helps users of giant fonts read long names + email addresses
6/8 because Perl has altered my brain :P
7/8 more use of this will follow in coming days
8/8 I couldn't resist low-hanging fruit
1/8 took longer for me than all the other changes here combined
Eric Wong (8):
view: generate query in single-message and commit views
viewdiff: linkify diffstats for non-format-patch emails
viewvcs: remove patchid line from commit header
viewvcs: show commit titles for parent commits
viewvcs: separate email and date with spaces
ibx_async_cat: access ->{git} directly
gzip_filter: ->zmore and ->zflush support multiple args
viewvcs: don't wait on slow disks for git commit titles
lib/PublicInbox/GitAsyncCat.pm | 2 +-
lib/PublicInbox/GzipFilter.pm | 15 ++--
lib/PublicInbox/View.pm | 37 ++++++++-
lib/PublicInbox/ViewDiff.pm | 45 ++++++-----
lib/PublicInbox/ViewVCS.pm | 140 +++++++++++++++++++++++----------
5 files changed, 167 insertions(+), 72 deletions(-)
^ permalink raw reply [relevance 7%]
* [PATCH 2/8] viewdiff: linkify diffstats for non-format-patch emails
2022-08-23 8:31 7% [PATCH 0/8] www: diff viewing enhancements Eric Wong
@ 2022-08-23 8:31 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-08-23 8:31 UTC (permalink / raw)
To: meta
Some folks unfortunately use "git diff --stat -p" to generate
patches. These messages lack the /^---$/ line and causing
diffstats to not get linkified properly. We now treat the
/^---$/ as optional and rely on the presence of file lines with
/ \| / proceeding a /\d+ files? changed,/ line.
---
lib/PublicInbox/ViewDiff.pm | 41 +++++++++++++++++--------------------
lib/PublicInbox/ViewVCS.pm | 2 +-
2 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index 960f7e61..ee2d688c 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -166,29 +166,26 @@ sub diff_before_or_after ($$) {
my ($ctx, $x) = @_;
my $linkify = $ctx->{-linkify};
my $dst = $ctx->{obuf};
- my $anchors = exists($ctx->{-anchors}) ? 1 : 0;
- for my $y (split(/(^---\n)/sm, $$x)) {
- if ($y =~ /\A---\n\z/s) {
- $$dst .= "---\n"; # all HTML is "\r\n" => "\n"
- $anchors |= 2;
- } elsif ($anchors == 3 && $y =~ /^ [0-9]+ files? changed, /sm) {
- # ok, looks like a diffstat, go line-by-line:
- for my $l (split(/^/m, $y)) {
- if ($l =~ /^ (.+)( +\| .*\z)/s) {
- anchor0($dst, $ctx, $1, $2) or
- $$dst .= $linkify->to_html($l);
- } elsif ($l =~ s/^( [0-9]+ files? )changed,//) {
- $$dst .= $1;
- my $end = $ctx->{end_id} // 'related';
- $$dst .= "<a href=#$end>changed</a>,";
- $$dst .= ascii_html($l);
- } else {
- $$dst .= $linkify->to_html($l);
- }
- }
- } else { # commit message, notes, etc
- $$dst .= $linkify->to_html($y);
+ if (exists $ctx->{-anchors} && $$x =~ /\A(.*?) # likely "---\n"
+ # diffstat lines:
+ ((?:^\x20(?:[^\n]+?)(?:\x20+\|\x20[^\n]*\n))+)
+ (\x20[0-9]+\x20files?\x20)changed,([^\n]+\n)
+ (.*?)\z/msx) { # notes, commit message, etc
+ undef $$x;
+ my @x = ($5, $4, $3, $2, $1);
+ $$dst .= $linkify->to_html(pop @x); # uninteresting prefix
+ for my $l (split(/^/m, pop(@x))) { # per-file diffstat lines
+ $l =~ /^ (.+)( +\| .*\z)/s and
+ anchor0($dst, $ctx, $1, $2) and next;
+ $$dst .= $linkify->to_html($l);
}
+ $$dst .= $x[2]; # $3 /^ \d+ files? /
+ my $end = $ctx->{end_id} // 'related';
+ $$dst .= "<a href=#$end>changed</a>,";
+ $$dst .= ascii_html($x[1]); # $4: insertions/deletions
+ $$dst .= $linkify->to_html($x[0]); # notes, commit message, etc
+ } else {
+ $$dst .= $linkify->to_html($$x);
}
}
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index dcb5c67f..4165a1de 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -153,10 +153,10 @@ EOM
$buf = '';
$ctx->{obuf} = \$buf;
$ctx->{-apfx} = $ctx->{-spfx} = $upfx;
- $ctx->{-anchors} = {};
$bdy = '';
read($fh, $bdy, -s _);
$bdy =~ s/\r?\n/\n/gs;
+ $ctx->{-anchors} = {} if $bdy =~ /^diff --git /sm;
flush_diff($ctx, \$bdy);
$ctx->zmore($buf);
undef $buf;
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-08-23 8:31 7% [PATCH 0/8] www: diff viewing enhancements Eric Wong
2022-08-23 8:31 7% ` [PATCH 2/8] viewdiff: linkify diffstats for non-format-patch emails Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).