- 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;
+
+ my @cmd = ('git', "--git-dir=$ctx->{git_dir}",
+ qw(cat-file blob), "HEAD:$1/$2");
+ my $cmd = join(' ', @cmd);
+ my $pid = open my $fh, '-|';
+ defined $pid or die "fork failed: $!\n";
+ if ($pid == 0) {
+ open STDERR, '>', '/dev/null'; # ignore errors
+ exec @cmd;
+ exit 1;
+ } else {
+ my $blob = eval { local $/; <$fh> };
+ close $fh;
+ $? == 0 ? \$blob : undef;
+ }