diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 55c80dba6..f59c6a68b 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -77,6 +77,7 @@ class GitDownloader extends VcsDownloader */ public function getLocalChanges($path) { + $this->cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { return; @@ -95,6 +96,7 @@ class GitDownloader extends VcsDownloader */ protected function cleanChanges($path, $update) { + $this->cleanEnv(); $path = $this->normalizePath($path); if (!$changes = $this->getLocalChanges($path)) { return; diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 3200688a9..6abb9c7c6 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -26,10 +26,16 @@ class Git } // added in git 1.7.1, prevents prompting the user for username/password - putenv('GIT_ASKPASS=echo'); + if (getenv('GIT_ASKPASS') !== 'echo') { + putenv('GIT_ASKPASS=echo'); + } // clean up rogue git env vars in case this is running in a git hook - putenv('GIT_DIR'); - putenv('GIT_WORK_TREE'); + if (getenv('GIT_DIR')) { + putenv('GIT_DIR'); + } + if (getenv('GIT_WORK_TREE')) { + putenv('GIT_WORK_TREE'); + } } }