public function _serialize() { $s = ''; $s .= sprintf("tree %s\n", Glip_Binary::sha1_hex($this->tree)); foreach ($this->parents as $parent) { $s .= sprintf("parent %s\n", Glip_Binary::sha1_hex($parent)); } $s .= sprintf("author %s\n", $this->author->serialize()); $s .= sprintf("committer %s\n", $this->committer->serialize()); $s .= "\n" . $this->summary . "\n" . $this->detail; return $s; }
public static function nfuint32($n, $f) { return Glip_Binary::nuint32($n, fread($f, 4 * $n)); }
/** * @brief Write this object in its serialized form to the git repository * given at creation time. */ public function write() { $sha1 = Glip_Binary::sha1_hex($this->name); $path = sprintf('%s/objects/%s/%s', $this->repo->dir, substr($sha1, 0, 2), substr($sha1, 2)); if (file_exists($path)) { return false; } $dir = dirname($path); if (!is_dir($dir)) { mkdir(dirname($path), 0770); } $f = fopen($path, 'ab'); flock($f, LOCK_EX); ftruncate($f, 0); $data = $this->serialize(); $data = Glip_Git::getTypeName($this->type) . ' ' . strlen($data) . "" . $data; fwrite($f, gzcompress($data)); fclose($f); return true; }