]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ViewVCS.pm
http: reuse STDIN if it's already /dev/null
[public-inbox.git] / lib / PublicInbox / ViewVCS.pm
index 00db8ff241a14e039ac6fc7a8ecaab37da3edb2c..60cc1376f29d49a9fe88988a9136e34cebb4a941 100644 (file)
@@ -62,8 +62,11 @@ sub dbg_log ($) {
                return '<pre>debug log seek error</pre>';
        }
        $log = do { local $/; <$log> } // do {
-               warn "readline(log): $!";
-               return '<pre>debug log read error</pre>';
+               if (!eof($log)) {
+                       warn "readline(log): $!";
+                       return '<pre>debug log read error</pre>';
+               }
+               '';
        };
        return '' if $log eq '';
        $ctx->{-linkify} //= PublicInbox::Linkify->new;
@@ -208,13 +211,15 @@ sub cmt_finalize {
                $au =~ s/>/>$x/;
        }
        $_ = ascii_html($_) for ($au, $co);
+       my $ibx_url = ibx_url_for($ctx) // $upfx;
        $au =~ s!(&gt; +)([0-9]{4,}-\S+ \S+)!
                my ($gt, $t) = ($1, $2);
                $t =~ tr/ :-//d;
                qq($gt<a
-href="$upfx?t=$t"
+href="$ibx_url?t=$t"
 title="list contemporary emails">$2</a>)
                !e;
+
        $ctx->{-title_html} = $s = $ctx->{-linkify}->to_html($s);
        my ($P, $p, $pt) = delete @$ctx{qw(-cmt_P -cmt_p -cmt_pt)};
        $_ = qq(<a href="$upfx$_/s/">).shift(@$p).'</a> '.shift(@$pt) for @$P;
@@ -500,8 +505,8 @@ sub solve_result {
        return show_tree($ctx, $res) if $type eq 'tree';
        return show_tag($ctx, $res) if $type eq 'tag';
        return show_other($ctx, $res) if $type ne 'blob';
+       my $fn = $di->{path_b} // $hints->{path_b};
        my $paths = $ctx->{-paths} //= do {
-               my $fn = $di->{path_b} // $hints->{path_b};
                my $path = to_filename($fn // 'blob');
                my $raw_more = qq[(<a\nhref="$path">raw</a>)];
 
@@ -510,6 +515,10 @@ sub solve_result {
 "\nname: ${\ascii_html($fn)} \t # note: path name is non-authoritative";
                [ $path, $raw_more ];
        };
+       $ctx->{-q_value_html} //= do {
+               my $s = defined($fn) ? 'dfn:'.ascii_html($fn).' ' : '';
+               $s.'dfpost:'.substr($oid, 0, 7);
+       };
 
        if ($size > $MAX_SIZE) {
                return stream_large_blob($ctx, $res) if defined $ctx->{fn};
@@ -580,7 +589,10 @@ sub show ($$;$) {
        }
        $ctx->{fn} = $fn;
        $ctx->{-tmp} = File::Temp->newdir("solver.$oid_b-XXXX", TMPDIR => 1);
-       open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log" or die "open: $!";
+       unless ($ctx->{lh}) {
+               open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log" or
+                       die "open: $!";
+       }
        my $solver = PublicInbox::SolverGit->new($ctx->{ibx},
                                                \&solve_result, $ctx);
        $solver->{gits} //= [ $ctx->{git} ];