indeyets/pake — Issue #18: bad quoting in git commands (pull and maybe others) on windows
Author: gggeek
Created: 2012-02-02 17:38:41+00:00
State: open

the escaping of the commands used for git cli should be fixed for it to work on windows: current code generates

git "--git-dir=d:\etc\/.git" "--work-tree=d:\etc\" pull

which gives this error:

.git""=="gui" was unexpected at this time.

a better syntax is

git --git-dir="d:\etc\/.git" --work-tree="d:\etc\" pull

The fix is the following:

private function git_run($command)
{
if (self::$needs_work_tree_workaround === true) {
$cmd = '(cd '.escapeshellarg($this->repository_path).' && git '.$command.')';
} else {
$cmd = 'git';
// here I would also maybe use the constant for DIRECTORY_SEPARATOR instead of /
$cmd .= ' --git-dir='.escapeshellarg($this->repository_path.'/.git');
$cmd .= ' --work-tree='.escapeshellarg($this->repository_path);
$cmd .= ' '.$command;
}
[...]