lib/PublicInbox/Git.pm | 9 ++++----- t/git.t | 8 ++++---- diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 3d97300c43c3f0fca345d6719d925d3b9ad652eb..c6c1c80205ae8556b1ee976417c37fa2e8baa7ed 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -240,17 +240,16 @@ _bidi_pipe($_[0], qw(--batch in out pid)); } sub _cat_file_cb { - my ($bref, undef, undef, $size, $result) = @_; - @$result = ($bref, $size); + my ($bref, $oid, $type, $size, $result) = @_; + @$result = ($bref, $oid, $type, $size); } sub cat_file { - my ($self, $oid, $sizeref) = @_; + my ($self, $oid) = @_; my $result = []; cat_async($self, $oid, \&_cat_file_cb, $result); cat_async_wait($self); - $$sizeref = $result->[1] if $sizeref; - $result->[0]; + wantarray ? @$result : $result->[0]; } sub check_async_step ($$) { diff --git a/t/git.t b/t/git.t index 377652ca8b5b7afb381774128e25eba2fb46ae75..0c85e492db00be62f5d56dedefb8abbc951c4e78 100644 --- a/t/git.t +++ b/t/git.t @@ -70,10 +70,10 @@ is(0, $?, 'hashed object successfully'); chomp $buf; my $gcf = PublicInbox::Git->new($dir); - my $rsize; - my $x = $gcf->cat_file($buf, \$rsize); - is($rsize, $size, 'got correct size ref on big file'); - is(length($$x), $size, 'read correct number of bytes'); + my @x = $gcf->cat_file($buf); + is($x[2], 'blob', 'got blob on wantarray'); + is($x[3], $size, 'got correct size ref on big file'); + is(length(${$x[0]}), $size, 'read correct number of bytes'); my $ref = $gcf->qx(qw(cat-file blob), $buf); is($?, 0, 'no error on scalar success');