private function initDir($gitDir, $workingDir = null)
{
$realGitDir = realpath($gitDir);
if (false === $realGitDir) {
throw new InvalidArgumentException(sprintf('Directory "%s" does not exist or is not a directory', $gitDir));
} else {
if (!is_dir($realGitDir)) {
throw new InvalidArgumentException(sprintf('Directory "%s" does not exist or is not a directory', $realGitDir));
} elseif (null === $workingDir && is_dir($realGitDir . '/.git')) {
$workingDir = $realGitDir;
$realGitDir = $realGitDir . '/.git';
}
}
$this->gitDir = $realGitDir;
$this->workingDir = $workingDir;
}