From: Eric Wong Date: Thu, 24 Dec 2015 11:36:33 +0000 (+0000) Subject: git: expand callback to support object ID and type X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3377b0c87167d6a8a4df5c8fa05be030e9b5caa4;p=thirdparty%2Fpublic-inbox.git git: expand callback to support object ID and type This metadata can be useful on an optional basis; allowing calls to $git->check to be skipped. --- diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 0f92dd9a8..4bc879ffd 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -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;