Reputation: 3918
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.
Upvotes: 2
Views: 231
Reputation: 81
Your problem is not with the --version but the problem is with the command you are executing to run git clone or git checkout.
You can't run git clone command or git checkout command with git.exe
while when you can run --version command with git.exe which is "C:/Program Files/Git/bin/git.exe" --version
So the conclusion is you have to set command while running git clone or git checkout your path should be
"C:/Program Files/Git/bin>" git clone or "C:/Program Files/Git/bin>" git checkout
Let me know if you still have an issue with that.
Thank you.
Upvotes: 1