]> Sergey Matveev's repositories - public-inbox.git/blobdiff - public-inbox.cgi
cgi: disable warnings for CGI::NOSTICKY
[public-inbox.git] / public-inbox.cgi
index 9314712431a54da4c8a345c741ff9c8e13bd59b9..b63223f509fc24cb05905e05c163c621303b7077 100755 (executable)
@@ -21,6 +21,7 @@ BEGIN {
        # TODO: detect and reload config as needed
        if ($ENV{MOD_PERL}) {
                require CGI;
+               no warnings;
                $CGI::NOSTICKY = 1;
                CGI->compile;
        }
@@ -142,12 +143,16 @@ sub get_index {
 # just returns a string ref for the blob in the current ctx
 sub mid2blob {
        my ($ctx) = @_;
-       local $ENV{GIT_DIR} = $ctx->{git_dir};
        require Digest::SHA;
        my $hex = Digest::SHA::sha1_hex($ctx->{mid});
        $hex =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/i or
                        die "BUG: not a SHA-1 hex: $hex";
-       my $blob = `git cat-file blob HEAD:$1/$2 2>/dev/null`;
+       require IPC::Run;
+       my ($in, $blob, $err);
+       open my $null, '+<', '/dev/null' or die "open: $!\n";
+       IPC::Run::run(['git', "--git-dir=$ctx->{git_dir}",
+                       qw(cat-file blob), "HEAD:$1/$2"],
+                       $null, \$blob, $null);
        $? == 0 ? \$blob : undef;
 }
 
@@ -218,7 +223,6 @@ sub psgi_app {
        require POSIX;
        require XML::Atom::SimpleFeed;
        require Plack::Request;
-       eval { require Git }; # optional
        sub {
                my $req = Plack::Request->new(@_);
                main($req, $req->method);