public function getObjectInfo($path, $ref = 'HEAD')
{
$info = array('type' => null, 'mode' => 0, 'size' => 0);
/** @var $result CallResult */
$result = $this->getGit()->{'cat-file'}($this->getRepositoryPath(), array('--batch-check'), sprintf('%s:%s', $ref, $path));
$result->assertSuccess(sprintf('Cannot cat-file "%s" at "%s" from "%s"', $path, $ref, $this->getRepositoryPath()));
$output = trim($result->getStdOut());
$parts = array();
if (preg_match('/^(?<sha1>[0-9a-f]{40}) (?<type>\\w+) (?<size>\\d+)$/', $output, $parts)) {
$mode = 0;
switch ($parts['type']) {
case 'tree':
$mode |= 040000;
break;
case 'blob':
$mode |= 0100000;
break;
}
$info['sha1'] = $parts['sha1'];
$info['type'] = $parts['type'];
$info['mode'] = (int) $mode;
$info['size'] = (int) $parts['size'];
}
return $info;
}