From 4c2c2325d2948ec5340e2fcafbee798cf568f5fd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Dec 2015 00:17:33 +0000 Subject: rename 'GitCatFile' package to 'Git' 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. --- lib/PublicInbox/SearchIdx.pm | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'lib/PublicInbox/SearchIdx.pm') diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index e9af547f..67272997 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -11,6 +11,7 @@ use strict; use warnings; use base qw(PublicInbox::Search); use PublicInbox::MID qw/mid_clean id_compress/; +require PublicInbox::Git; *xpfx = *PublicInbox::Search::xpfx; use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian @@ -331,16 +332,11 @@ sub rlog { my $h40 = $hex .'{40}'; my $addmsg = qr!^:000000 100644 \S+ ($h40) A\t${hex}{2}/${hex}{38}$!; my $delmsg = qr!^:100644 000000 ($h40) \S+ D\t${hex}{2}/${hex}{38}$!; - my $git_dir = $self->{git_dir}; - require PublicInbox::GitCatFile; - my $git = PublicInbox::GitCatFile->new($git_dir); - my @cmd = ('git', "--git-dir=$git_dir", "log", - qw/--reverse --no-notes --no-color --raw -r --no-abbrev/, - $range); + my $git = PublicInbox::Git->new($self->{git_dir}); + my $log = $git->popen(qw/log --reverse --no-notes --no-color + --raw -r --no-abbrev/, $range); my $latest; my $bytes; - my $pid = open(my $log, '-|', @cmd) or - die('open` '.join(' ', @cmd) . " pipe failed: $!\n"); while (my $line = <$log>) { if ($line =~ /$addmsg/o) { my $mime = do_cat_mail($git, $1, \$bytes) or next; @@ -447,10 +443,8 @@ sub merge_threads { sub _read_git_config_perm { my ($self) = @_; - my @cmd = ('git', "--git-dir=$self->{git_dir}", - qw(config core.sharedRepository)); - my $pid = open(my $fh, '-|', @cmd) or - die('open `'.join(' ', @cmd) . " pipe failed: $!\n"); + my @cmd = qw(config core.sharedRepository); + my $fh = PublicInbox::Git->new($self->{git_dir})->popen(@cmd); my $perm = <$fh>; close $fh; chomp $perm if defined $perm; -- cgit v1.2.3-24-ge0c7