I am trying to use PHING to check out a git repository as part of a build process. PHING uses pear/versioncontrol_git to handle git tasks. My path to git is C:\Program Files\Git\bin\git.exe.
Two commands are run using this path, <gitpath> --version and <gitpath> clone -q -repo=...
<gitpath> --version works fine. <gitpath> clone... gives an error that C:\Program is not a valid path. I am confused why this would be a problem when the exact same code can execute the --version command with no error.
What appears to be happening is that the quotes are getting stripped off, but only sometimes.
This is the offending code:
public function execute($arguments = array(), $options = array())
{
$command = $this->createCommandString($arguments, $options);
$descriptorspec = array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$pipes = array();
$resource = proc_open($command, $descriptorspec, $pipes, realpath($this->git->getDirectory()));
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
foreach ($pipes as $pipe) {
fclose($pipe);
}
$status = trim(proc_close($resource));
if ($status) {
$message = "Some errors in executing git command . $command\n\n"
. "Output:\n"
. $stdout."\n"
. "Error:\n"
. $stderr;
var_dump($message);
throw new VersionControl_Git_Exception($message);
} else {
var_dump('No errors in ' . $command);
}
return $this->stripEscapeSequence($stdout);
}
And this is the output of two calls to the code:
C:\PHP Projects\Build\vendor\pear\versioncontrol_git\VersionControl\Git\Util\Command.php:240:
string(61) "No errors in "C:\\Program Files\\Git\\bin\\git.exe" --version"
C:\PHP Projects\Build\vendor\pear\versioncontrol_git\VersionControl\Git\Util\Command.php:237:
string(306) "Some errors in executing git command . "C:\\Program Files\\Git\\bin\\git.exe" clone -q --branch="master" "--REDACTED--" "C:\PHP Projects\Build\build"
Output:
Error:
'C:\\Program' is not recognized as an internal or external command,
operable program or batch file.