public function getCommit(Environment $environment, $sha = null)
    {
        $sha = $this->normalizeSha($environment, $sha);
        if ($sha === null) {
            return false;
        }

        $parents = $this->parseParents($sha);
        $sha = preg_replace('/[\^~].*$/', '', $sha);

        // Get the first commit.
        $commit = $this->getCommitByShaHash($environment, $sha);
        if (!$commit) {
            return false;
        }

        // Fetch parent commits recursively.
        while ($commit !== false && count($parents)) {
            $parent = array_shift($parents);
            if (isset($commit->parents[$parent - 1])) {
                $commit = $this->getCommitByShaHash($environment, $commit->parents[$parent - 1]);
            } else {
                return false;
            }
        }

        return $commit;
    }