]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git: expand callback to support object ID and type
authorEric Wong <e@80x24.org>
Thu, 24 Dec 2015 11:36:33 +0000 (11:36 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Apr 2016 18:58:27 +0000 (18:58 +0000)
This metadata can be useful on an optional basis; allowing
calls to $git->check to be skipped.

lib/PublicInbox/Git.pm

index 0f92dd9a82f6e70bc5de58661fbfab0bce76bd47..4bc879ffd9b6b497bd7fda818fdf1e91a1590b30 100644 (file)
@@ -43,10 +43,10 @@ sub cat_file {
        my $in = $self->{in};
        my $head = $in->getline;
        $head =~ / missing$/ and return undef;
-       $head =~ /^[0-9a-f]{40} \S+ (\d+)$/ or
+       $head =~ /^([0-9a-f]{40}) (\S+) (\d+)$/ or
                fail($self, "Unexpected result from git cat-file: $head");
 
-       my $size = $1;
+       my ($hex, $type, $size) = ($1, $2, $3);
        my $ref_type = $ref ? ref($ref) : '';
 
        my $rv;
@@ -55,7 +55,7 @@ sub cat_file {
        my $cb_err;
 
        if ($ref_type eq 'CODE') {
-               $rv = eval { $ref->($in, \$left) };
+               $rv = eval { $ref->($in, \$left, $type, $hex) };
                $cb_err = $@;
                # drain the rest
                my $max = 8192;