From d679cbb1b5ad95d2689bc3b8f78da2b380fc7860 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 29 Jan 2021 12:42:58 +0500 Subject: git: synchronous cat_file may return type and OID Instead of forcing callers to set a variable to write into, we'll just rely on wantarray. --- lib/PublicInbox/Git.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 3d97300c..c6c1c802 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -240,17 +240,16 @@ sub batch_prepare ($) { } 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 ($$) { -- cgit v1.2.3-24-ge0c7