From 81b2b84112a36f93c5032434b094469f1f22cf2b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 19 Jun 2013 11:44:16 +0200 Subject: [PATCH] Clean up git env vars consistently --- src/Composer/Downloader/GitDownloader.php | 2 ++ src/Composer/Util/Git.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) 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'); + } } }