about summary refs log tree commit homepage
path: root/lib/PublicInbox/ViewVCS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-17 23:37:52 +0000
committerEric Wong <e@80x24.org>2023-10-18 20:50:24 +0000
commit19b791f4894efcb6e545a6b51c8147298363358f (patch)
tree16a806fcb0c8fdaef242a2d268a8b1416809b46f /lib/PublicInbox/ViewVCS.pm
parent35b0f7aa00a24f5d89b1b941ec644327ba074c99 (diff)
downloadpublic-inbox-19b791f4894efcb6e545a6b51c8147298363358f.tar.gz
`readline' ops may not detect errors on partial reads.
This saves us some code to reduce cognitive overhead for
readers.  We'll also support reusing a destination buffers so it
can work more nicely with existing code.
Diffstat (limited to 'lib/PublicInbox/ViewVCS.pm')
-rw-r--r--lib/PublicInbox/ViewVCS.pm12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 8a90c2d6..86c46e69 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -17,6 +17,7 @@ use strict;
 use v5.10.1;
 use File::Temp 0.19 (); # newdir
 use PublicInbox::SolverGit;
+use PublicInbox::Git qw(read_all);
 use PublicInbox::GitAsyncCat;
 use PublicInbox::WwwStream qw(html_oneshot);
 use PublicInbox::Linkify;
@@ -61,12 +62,9 @@ sub dbg_log ($) {
                 warn "seek(log): $!";
                 return '<pre>debug log seek error</pre>';
         }
-        $log = do { local $/; <$log> } // do {
-                if (!eof($log)) {
-                        warn "readline(log): $!";
-                        return '<pre>debug log read error</pre>';
-                }
-                '';
+        $log = eval { read_all($log) } // do {
+                warn "read(log): $@";
+                return '<pre>debug log read error</pre>';
         };
         return '' if $log eq '';
         $ctx->{-linkify} //= PublicInbox::Linkify->new;
@@ -251,7 +249,7 @@ EOM
         if (-s $fh > $MAX_SIZE) {
                 print $zfh "---\n patch is too large to show\n";
         } else { # prepare flush_diff:
-                read($fh, $x, -s _);
+                read_all($fh, -s _, \$x);
                 utf8_maybe($x);
                 $ctx->{-apfx} = $ctx->{-spfx} = $upfx;
                 $x =~ s/\r?\n/\n/gs;