about summary refs log tree commit homepage
path: root/lib/PublicInbox/ViewVCS.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/ViewVCS.pm')
-rw-r--r--lib/PublicInbox/ViewVCS.pm34
1 files changed, 10 insertions, 24 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index f47c2703..b69214bc 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -106,7 +106,7 @@ sub stream_large_blob ($$) {
         my ($ctx, $res) = @_;
         $ctx->{-res} = $res;
         my ($git, $oid, $type, $size, $di) = @$res;
-        my $cmd = ['git', "--git-dir=$git->{git_dir}", 'cat-file', $type, $oid];
+        my $cmd = $git->cmd('cat-file', $type, $oid);
         my $qsp = PublicInbox::Qspawn->new($cmd);
         $ctx->{env}->{'qspawn.wcb'} = $ctx->{-wcb};
         $qsp->psgi_yield($ctx->{env}, undef, \&stream_blob_parse_hdr, $ctx);
@@ -251,7 +251,7 @@ href="$ibx_url?t=$t"
 title="list contemporary emails">$2</a>)
                 !e;
 
-        $ctx->{-title_html} = $s = $ctx->{-linkify}->to_html($s);
+        my $title_html = $ctx->{-title_html} = $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;
         if (@$P == 1) {
@@ -273,7 +273,7 @@ href="$f.patch">patch</a>)\n   <a href=#parent>parent</a> $P->[0]};
    author $au
 committer $co
 
-<b>$s</b>
+<b>$title_html</b>
 EOM
         print $zfh "\n", $ctx->{-linkify}->to_html($bdy) if length($bdy);
         undef $bdy; # free memory
@@ -291,20 +291,8 @@ EOM
                 # TODO: should there be another textarea which attempts to
                 # search for the exact email which was applied to make this
                 # commit?
-                if (my $qry = delete $ctx->{-qry}) {
-                        my $q = '';
-                        for (@{$qry->{dfpost}}, @{$qry->{dfpre}}) {
-                                # keep blobs as short as reasonable, emails
-                                # are going to be older than what's in git
-                                substr($_, 7, 64, '');
-                                $q .= "dfblob:$_ ";
-                        }
-                        chop $q; # no trailing SP
-                        local $Text::Wrap::columns = PublicInbox::View::COLS;
-                        local $Text::Wrap::huge = 'overflow';
-                        $q = wrap('', '', $q);
-                        my $rows = ($q =~ tr/\n/\n/) + 1;
-                        $q = ascii_html($q);
+                my ($rows, $q) = PublicInbox::View::dfqry_text $ctx, $s;
+                if ($rows) {
                         my $ibx_url = ibx_url_for($ctx);
                         my $alt;
                         if (defined $ibx_url) {
@@ -368,10 +356,9 @@ sub stream_patch_parse_hdr { # {parse_hdr} for Qspawn
 sub show_patch ($$) {
         my ($ctx, $res) = @_;
         my ($git, $oid) = @$res;
-        my @cmd = ('git', "--git-dir=$git->{git_dir}",
-                qw(format-patch -1 --stdout -C),
+        my $cmd = $git->cmd(qw(format-patch -1 --stdout -C),
                 "--signature=git format-patch -1 --stdout -C $oid", $oid);
-        my $qsp = PublicInbox::Qspawn->new(\@cmd);
+        my $qsp = PublicInbox::Qspawn->new($cmd);
         $ctx->{env}->{'qspawn.wcb'} = $ctx->{-wcb};
         $ctx->{patch_oid} = $oid;
         $qsp->psgi_yield($ctx->{env}, undef, \&stream_patch_parse_hdr, $ctx);
@@ -400,8 +387,8 @@ sub show_other ($$) { # just in case...
         my ($git, $oid, $type, $size) = @$res;
         $size > $MAX_SIZE and return html_page($ctx, 200,
                 ascii_html($type)." $oid is too big to show\n". dbg_log($ctx));
-        my $cmd = ['git', "--git-dir=$git->{git_dir}",
-                qw(show --encoding=UTF-8 --no-color --no-abbrev), $oid ];
+        my $cmd = $git->cmd(qw(show --encoding=UTF-8
+                        --no-color --no-abbrev), $oid);
         my $qsp = PublicInbox::Qspawn->new($cmd);
         $qsp->{qsp_err} = \($ctx->{-qsp_err} = '');
         $qsp->psgi_qx($ctx->{env}, undef, \&show_other_result, $ctx);
@@ -487,8 +474,7 @@ sub show_tree ($$) { # also used by RepoTree
         my ($git, $oid, undef, $size) = @$res;
         $size > $MAX_SIZE and return html_page($ctx, 200,
                         "tree $oid is too big to show\n". dbg_log($ctx));
-        my $cmd = [ 'git', "--git-dir=$git->{git_dir}",
-                qw(ls-tree -z -l --no-abbrev), $oid ];
+        my $cmd = $git->cmd(qw(ls-tree -z -l --no-abbrev), $oid);
         my $qsp = PublicInbox::Qspawn->new($cmd);
         $ctx->{tree_oid} = $oid;
         $qsp->{qsp_err} = \($ctx->{-qsp_err} = '');