]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Git.pm
rename 'GitCatFile' package to 'Git'
[public-inbox.git] / lib / PublicInbox / Git.pm
similarity index 92%
rename from lib/PublicInbox/GitCatFile.pm
rename to lib/PublicInbox/Git.pm
index b3666a088d1e4b0784cd89f1f4e7ce405897bd3b..5135862e6ad51bc904e880f94175239d59519707 100644 (file)
@@ -6,7 +6,7 @@
 # This is based on code in Git.pm which is GPLv2, but modified to avoid
 # dependence on environment variables for compatibility with mod_perl.
 # There are also API changes to simplify our usage and data set.
-package PublicInbox::GitCatFile;
+package PublicInbox::Git;
 use strict;
 use warnings;
 use POSIX qw(dup2);
@@ -121,6 +121,16 @@ sub fail {
        die $msg;
 }
 
+sub popen {
+       my ($self, @cmd) = @_;
+       my $mode = '-|';
+       $mode = shift @cmd if ($cmd[0] eq '|-');
+       @cmd = ('git', "--git-dir=$self->{git_dir}", @cmd);
+       my $pid = open my $fh, $mode, @cmd or
+               die('open `'.join(' ', @cmd) . " pipe failed: $!\n");
+       $fh;
+}
+
 sub cleanup {
        my ($self) = @_;
        _destroy($self, qw(in out pid));