diff options
author | Eric Wong <e@80x24.org> | 2019-01-20 09:42:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-20 09:42:34 +0000 |
commit | a01040ed2ec1e4575947e6d589499a4c7315d90e (patch) | |
tree | eacf2ad2c84ab5e49f8a204b20dbf9d5b661313e /lib/PublicInbox/ViewDiff.pm | |
parent | c2d12f79e78eb4ea909cac6106880c0f41e8c5fd (diff) | |
download | public-inbox-a01040ed2ec1e4575947e6d589499a4c7315d90e.tar.gz |
Having diff highlighting alone is still useful, even if blob-resolution/recreation is too expensive or unfeasible.
Diffstat (limited to 'lib/PublicInbox/ViewDiff.pm')
-rw-r--r-- | lib/PublicInbox/ViewDiff.pm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 1aad2832..0d1aefb7 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -40,7 +40,8 @@ sub diff_hunk ($$$$) { my $oid_a = $dctx->{oid_a}; my $oid_b = $dctx->{oid_b}; - (defined($oid_a) && defined($oid_b)) or return "@@ $ca $cb @@"; + (defined($spfx) && defined($oid_a) && defined($oid_b)) or + return "@@ $ca $cb @@"; my ($n) = ($ca =~ /^-(\d+)/); $n = defined($n) ? do { ++$n; "#n$n" } : ''; @@ -53,6 +54,11 @@ sub diff_hunk ($$$$) { $rv .= qq( <a\nhref=$spfx$oid_b/s/$dctx->{Q}$n>$cb</a> @@); } +sub oid ($$$) { + my ($dctx, $spfx, $oid) = @_; + defined($spfx) ? qq(<a\nhref=$spfx$oid/s/$dctx->{Q}>$oid</a>) : $oid; +} + sub flush_diff ($$$$) { my ($dst, $spfx, $linkify, $diff) = @_; my $state = DSTATE_INIT; @@ -90,11 +96,10 @@ sub flush_diff ($$$$) { } $$dst .= to_html($linkify, $s); } elsif ($s =~ s/^(index $OID_NULL\.\.)($OID_BLOB)\b//o) { - $$dst .= qq($1<a\nhref=$spfx$2/s/$dctx->{Q}>$2</a>); + $$dst .= $1 . oid($dctx, $spfx, $2); $$dst .= to_html($linkify, $s) ; } elsif ($s =~ s/^index ($OID_NULL)(\.\.$OID_BLOB)\b//o) { - $$dst .= 'index '; - $$dst .= qq(<a\nhref=$spfx$1/s/$dctx->{Q}>$1</a>$2); + $$dst .= 'index ' . oid($dctx, $spfx, $1) . $2; $$dst .= to_html($linkify, $s); } elsif ($s =~ /^index ($OID_BLOB)\.\.($OID_BLOB)/o) { $dctx->{oid_a} = $1; |