diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 2eb40bb1b..d1c072ecf 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -30,7 +30,8 @@ class GitDownloader extends VcsDownloader $this->cleanEnv(); $ref = $package->getSourceReference(); - $command = 'git clone %s %s && cd %2$s && git remote add composer %1$s && git fetch composer'; + $flag = defined('PHP_WINDOWS_VERSION_MAJOR') ? '/D ' : ''; + $command = 'git clone %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; $this->io->write(" Cloning ".$ref); $commandCallable = function($url) use ($ref, $path, $command) { diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 2637c5e6a..2da584c03 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -300,6 +300,8 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase private function getCmd($cmd) { if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $cmd = str_replace('cd ', 'cd /D ', $cmd); + return strtr($cmd, "'", '"'); }