Gittern\Transport\PackfileIndex::getOffsetForSha PHP Method

getOffsetForSha() protected method

protected getOffsetForSha ( $sha )
    protected function getOffsetForSha($sha)
    {
        $prefix = hexdec(substr($sha, 0, 2));
        $start = $this->getStartOffsetForPrefix($prefix);
        $stop = $this->getStopOffsetForPrefix($prefix);
        $counter = $this->getStartCounterForPrefix($prefix);
        $this->reader->setOffset($start);
        do {
            $read_sha = $this->reader->readHHex(20);
            if ($read_sha == $sha) {
                return $counter;
            }
            $read_prefix = hexdec(substr($read_sha, 0, 2));
            $counter++;
        } while ($read_prefix <= $prefix && $this->reader->getOffset() < $stop);
        throw new IndexEntryNotFoundException("SHA {$sha} is not in packfile index");
    }