Gittern\Transport\Packfile::patchDelta PHP Метод

patchDelta() защищенный Метод

См. также: https://github.com/mojombo/grit/blob/master/lib/grit/git-ruby/internal/pack.rb
protected patchDelta ( $delta, RawObject $base_object )
$base_object RawObject
    protected function patchDelta($delta, RawObject $base_object)
    {
        $base = $base_object->getData();
        list($src_size, $pos) = $this->patchDeltaHeaderSize($delta, 0);
        if ($src_size != strlen($base)) {
            throw new InvalidPackfileException("Packfile delta is invalid");
        }
        list($dest_size, $pos) = $this->patchDeltaHeaderSize($delta, $pos);
        $dest = "";
        while ($pos < strlen($delta)) {
            $c = ord($delta[$pos++]);
            if ($c & 0x80) {
                $cp_off = $cp_size = 0;
                if ($c & 0x1) {
                    $cp_off = ord($delta[$pos++]);
                }
                if ($c & 0x2) {
                    $cp_off |= ord($delta[$pos++]) << 8;
                }
                if ($c & 0x4) {
                    $cp_off |= ord($delta[$pos++]) << 16;
                }
                if ($c & 0x8) {
                    $cp_off |= ord($delta[$pos++]) << 24;
                }
                if ($c & 0x10) {
                    $cp_size = ord($delta[$pos++]);
                }
                if ($c & 0x20) {
                    $cp_size |= ord($delta[$pos++]) << 8;
                }
                if ($c & 0x40) {
                    $cp_size |= ord($delta[$pos++]) << 16;
                }
                if ($cp_size == 0) {
                    $cp_size = 0x10000;
                }
                $dest .= substr($base, $cp_off, $cp_size);
            } elseif ($c != 0) {
                $dest .= substr($delta, $pos, $c);
                $pos += $c;
            } else {
                throw new InvalidPackfileException("Packfile delta is invalid");
            }
        }
        return $dest;
    }