protected function doClone(VersionControl_Git $client)
    {
        $command = $client->getCommand('clone')
            ->setOption('q')
            ->setOption('bare', $this->isBare())
            ->setOption('single-branch', $this->isSingleBranch())
            ->setOption('depth', $this->hasDepth() ? $this->getDepth() : false)
            ->setOption('branch', $this->hasBranch() ? $this->getBranch() : false)
            ->addArgument($this->getRepository())
            ->addArgument($this->getTargetPath());

        if (is_dir($this->getTargetPath()) && version_compare('1.6.1.4', $client->getGitVersion(), '>=')) {
            $isEmptyDir = true;
            $entries = scandir($this->getTargetPath());
            foreach ($entries as $entry) {
                if ('.' !== $entry && '..' !== $entry) {
                    $isEmptyDir = false;

                    break;
                }
            }

            if ($isEmptyDir) {
                @rmdir($this->getTargetPath());
            }
        }

        $command->execute();
    }