summaryrefslogtreecommitdiffstats
path: root/3rdparty/granite/git/object/loose.php
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/granite/git/object/loose.php')
-rw-r--r--3rdparty/granite/git/object/loose.php81
1 files changed, 0 insertions, 81 deletions
diff --git a/3rdparty/granite/git/object/loose.php b/3rdparty/granite/git/object/loose.php
deleted file mode 100644
index 32f894845b9..00000000000
--- a/3rdparty/granite/git/object/loose.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * Loose - provides a 'loose object' object
- *
- * PHP version 5.3
- *
- * @category Git
- * @package Granite
- * @author Craig Roberts <craig0990@googlemail.com>
- * @license http://www.opensource.org/licenses/mit-license.php MIT Expat License
- * @link http://craig0990.github.com/Granite/
- */
-
-namespace Granite\Git\Object;
-use \UnexpectedValueException as UnexpectedValueException;
-
-/**
- * Loose represents a loose object in the Git repository
- *
- * @category Git
- * @package Granite
- * @author Craig Roberts <craig0990@googlemail.com>
- * @license http://www.opensource.org/licenses/mit-license.php MIT Expat License
- * @link http://craig0990.github.com/Granite/
- */
-class Loose extends Raw
-{
-
- /**
- * Reads an object from a loose object file based on the SHA-1 id
- *
- * @param string $path The path to the repository root
- * @param string $sha The SHA-1 id of the requested object
- *
- * @throws UnexpectedValueException If the type is not 'commit', 'tree',
- * 'tag' or 'blob'
- */
- public function __construct($path, $sha)
- {
- $this->sha = $sha;
-
- $loose_path = $path
- . 'objects/'
- . substr($sha, 0, 2)
- . '/'
- . substr($sha, 2);
-
- if (!file_exists($loose_path)) {
- throw new InvalidArgumentException("Cannot open loose object file for $sha");
- }
-
- $raw = gzuncompress(file_get_contents($loose_path));
- $data = explode("\0", $raw, 2);
-
- $header = $data[0];
- $this->content = $data[1];
-
- list($this->type, $this->size) = explode(' ', $header);
-
- switch ($this->type) {
- case 'commit':
- $this->type = Raw::OBJ_COMMIT;
- break;
- case 'tree':
- $this->type = Raw::OBJ_TREE;
- break;
- case 'blob':
- $this->type = Raw::OBJ_BLOB;
- break;
- case 'tag':
- $this->type = Raw::OBJ_TAG;
- break;
- default:
- throw new UnexpectedValueException(
- "Unexpected type '{$this->type}'"
- );
- break;
- }
- }
-
-}