summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/recentchangesdiff.pm15
-rw-r--r--IkiWiki/Rcs/Stub.pm3
-rw-r--r--IkiWiki/Rcs/git.pm16
-rw-r--r--IkiWiki/Rcs/svn.pm2
-rw-r--r--IkiWiki/Rcs/tla.pm2
5 files changed, 26 insertions, 12 deletions
diff --git a/IkiWiki/Plugin/recentchangesdiff.pm b/IkiWiki/Plugin/recentchangesdiff.pm
index bd2826f76..3942f308b 100644
--- a/IkiWiki/Plugin/recentchangesdiff.pm
+++ b/IkiWiki/Plugin/recentchangesdiff.pm
@@ -5,6 +5,8 @@ use warnings;
use strict;
use IkiWiki 2.00;
+my $maxlines=200;
+
sub import { #{{{
hook(type => "pagetemplate", id => "recentchangesdiff",
call => \&pagetemplate);
@@ -15,8 +17,17 @@ sub pagetemplate (@) { #{{{
my $template=$params{template};
if ($config{rcs} && exists $params{rev} && length $params{rev} &&
$template->query(name => "diff")) {
- my $diff=IkiWiki::rcs_diff($params{rev});
- if (defined $diff && length $diff) {
+ my @lines=IkiWiki::rcs_diff($params{rev});
+ if (@lines) {
+ my $diff;
+ if (@lines > $maxlines) {
+ # only include so many lines of diff
+ $diff=join("", @lines[0..($maxlines-1)])."\n".
+ gettext("(Diff truncated)");
+ }
+ else {
+ $diff=join("", @lines);
+ }
# escape links and preprocessor stuff
$diff =~ s/(?<!\\)\[\[/\\\[\[/g;
$template->param(diff => $diff);
diff --git a/IkiWiki/Rcs/Stub.pm b/IkiWiki/Rcs/Stub.pm
index d94daf8bc..a460f29a2 100644
--- a/IkiWiki/Rcs/Stub.pm
+++ b/IkiWiki/Rcs/Stub.pm
@@ -60,7 +60,8 @@ sub rcs_recentchanges ($) {
sub rcs_diff ($) {
# Optional, used to get diffs for recentchanges.
# The parameter is the rev from rcs_recentchanges.
- return "";
+ # Should return a list of lines of the diff (including \n) in list
+ # context, and the whole diff in scalar context.
}
sub rcs_getctime ($) {
diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm
index 9306a513e..1882b43ef 100644
--- a/IkiWiki/Rcs/git.pm
+++ b/IkiWiki/Rcs/git.pm
@@ -414,16 +414,18 @@ sub rcs_recentchanges ($) { #{{{
sub rcs_diff ($) { #{{{
my $rev=shift;
my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
- my $ret;
+ my @lines;
foreach my $line (run_or_non("git", "show", $sha1)) {
- if (defined $ret) {
- $ret.=$line."\n";
- }
- elsif ($line=~/^diff --git/) {
- $ret=$line."\n";
+ if (@lines || $line=~/^diff --git/) {
+ push @lines, $line."\n";
}
}
- return $ret;
+ if (wantarray) {
+ return @lines;
+ }
+ else {
+ return join("", @lines);
+ }
} #}}}
sub rcs_getctime ($) { #{{{
diff --git a/IkiWiki/Rcs/svn.pm b/IkiWiki/Rcs/svn.pm
index 7bad40747..ea193e08f 100644
--- a/IkiWiki/Rcs/svn.pm
+++ b/IkiWiki/Rcs/svn.pm
@@ -219,7 +219,7 @@ sub rcs_recentchanges ($) { #{{{
sub rcs_diff ($) { #{{{
my $rev=possibly_foolish_untaint(int(shift));
- return scalar `svnlook diff $config{svnrepo} -r$rev --no-diff-deleted`;
+ return `svnlook diff $config{svnrepo} -r$rev --no-diff-deleted`;
} #}}}
sub rcs_getctime ($) { #{{{
diff --git a/IkiWiki/Rcs/tla.pm b/IkiWiki/Rcs/tla.pm
index 2890ff8c7..47579c15b 100644
--- a/IkiWiki/Rcs/tla.pm
+++ b/IkiWiki/Rcs/tla.pm
@@ -171,7 +171,7 @@ sub rcs_diff ($) { #{{{
}
my $revminusone = $changesets[$i+1];
- return scalar `tla diff -d $config{srcdir} $revminusone`;
+ return `tla diff -d $config{srcdir} $revminusone`;
} #}}}
sub rcs_getctime ($) { #{{{