about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchView.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-22 00:17:33 +0000
committerEric Wong <e@80x24.org>2015-12-22 00:58:13 +0000
commit4c2c2325d2948ec5340e2fcafbee798cf568f5fd (patch)
tree85dd6e48f4b7c658cb3eee12032143839000f218 /lib/PublicInbox/SearchView.pm
parentb140961420c0f240c9c3f55e83c52cfc3efa709d (diff)
downloadpublic-inbox-4c2c2325d2948ec5340e2fcafbee798cf568f5fd.tar.gz
We'll be using it for more than just cat-file.
Adding a `popen' API for internal use allows us to save a bunch
of code in other places.
Diffstat (limited to 'lib/PublicInbox/SearchView.pm')
-rw-r--r--lib/PublicInbox/SearchView.pm9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index ea8a45a4..fec4f39f 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -10,6 +10,7 @@ use PublicInbox::Hval;
 use PublicInbox::View;
 use PublicInbox::MID qw(mid2path mid_clean);
 use Email::MIME;
+require PublicInbox::Git;
 our $LIM = 50;
 
 sub sres_top_html {
@@ -169,12 +170,10 @@ sub tdump {
                 $th->order(*PublicInbox::View::rsort_ts);
         }
 
-        require PublicInbox::GitCatFile;
-        my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
+        my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
         my $state = { ctx => $ctx, anchor_idx => 0, pct => \%pct };
         $ctx->{searchview} = 1;
         tdump_ent($fh, $git, $state, $_, 0) for $th->rootset;
-        $git = undef;
         Email::Address->purge_cache;
 
         $fh->write(search_nav_bot($mset, $q). "\n\n" .
@@ -236,8 +235,7 @@ sub html_start {
 sub adump {
         my ($cb, $mset, $q, $ctx) = @_;
         my $fh = $cb->([ 200, ['Content-Type' => 'application/atom+xml']]);
-        require PublicInbox::GitCatFile;
-        my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
+        my $git = $ctx->{git_dir} ||= PublicInbox::Git->new($ctx->{git_dir});
         my $feed_opts = PublicInbox::Feed::get_feedopts($ctx);
         my $x = PublicInbox::Hval->new_oneline($q->{q})->as_html;
         $x = qq{$x - search results};
@@ -251,7 +249,6 @@ sub adump {
                 $x = mid2path($x);
                 PublicInbox::Feed::add_to_feed($feed_opts, $fh, $x, $git);
         }
-        $git = undef;
         PublicInbox::Feed::end_feed($fh);
 }