From f304611014421624a3b4e4a264311de1b9e68380 Mon Sep 17 00:00:00 2001 From: Colin O'Dell Date: Fri, 14 Nov 2014 10:31:52 -0500 Subject: [PATCH] Fix Git failures due to tag ambiguity (issue #3417) --- src/Composer/Downloader/GitDownloader.php | 4 ++-- tests/Composer/Test/Downloader/GitDownloaderTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index bdebaf4cf..b81a7fb79 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -215,7 +215,7 @@ class GitDownloader extends VcsDownloader */ protected function updateToCommit($path, $reference, $branch, $date) { - $template = 'git checkout %s && git reset --hard %1$s'; + $template = 'git checkout %s && git reset --hard %1$s --'; $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch); $branches = null; @@ -247,7 +247,7 @@ class GitDownloader extends VcsDownloader if (0 === $this->process->execute($command, $output, $path) || 0 === $this->process->execute($fallbackCommand, $output, $path) ) { - $command = sprintf('git reset --hard %s', ProcessExecutor::escape($reference)); + $command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference)); if (0 === $this->process->execute($command, $output, $path)) { return; } diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 05cc8f30e..0d3d58518 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -79,7 +79,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase $processExecutor->expects($this->at(3)) ->method('execute') - ->with($this->equalTo($this->winCompat("git reset --hard '1234567890123456789012345678901234567890'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath'))) + ->with($this->equalTo($this->winCompat("git reset --hard '1234567890123456789012345678901234567890' --")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath'))) ->will($this->returnValue(0)); $downloader = $this->getDownloaderMock(null, null, $processExecutor); @@ -134,7 +134,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase $processExecutor->expects($this->at(6)) ->method('execute') - ->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath'))) + ->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref' --")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath'))) ->will($this->returnValue(0)); $downloader = $this->getDownloaderMock(null, new Config(), $processExecutor); @@ -266,7 +266,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(0)); $processExecutor->expects($this->at(4)) ->method('execute') - ->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat($tmpDir))) + ->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref' --")), $this->equalTo(null), $this->equalTo($this->winCompat($tmpDir))) ->will($this->returnValue(0)); $downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);