- my ($git, $class, $sha1) = @_;
- my $str;
- if ($git) {
- open my $fh, '>', \$str or
- die "failed to setup string handle: $!\n";
- binmode $fh;
- my $bytes = $git->cat_blob($sha1, $fh);
- close $fh or die "failed to close string handle: $!\n";
- return if $bytes <= 0;
- } else {
- $str = `git cat-file blob $sha1`;
- return if $? != 0 || length($str) == 0;
- }
- $class->new($str);