Get rid of git exe singleton
Get rid of git exe singleton

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -128,9 +128,11 @@
 	 */
 	protected function InitializeGitExe($validate = true)
 	{
-		$this->exe = GitPHP_GitExe::GetInstance();
+		$this->exe = new GitPHP_GitExe($this->config->GetValue('gitbin'));
+		if ($this->log)
+			$this->exe->AddObserver($this->log);
 		if ($validate && !$this->exe->Valid()) {
-			throw new GitPHP_MessageException(sprintf(__('Could not run the git executable "%1$s".  You may need to set the "%2$s" config value.'), GitPHP_GitExe::GetInstance()->GetBinary(), 'gitbin'), true, 500);
+			throw new GitPHP_MessageException(sprintf(__('Could not run the git executable "%1$s".  You may need to set the "%2$s" config value.'), $this->exe->GetBinary(), 'gitbin'), true, 500);
 		}
 	}
 

--- a/include/git/GitExe.class.php
+++ b/include/git/GitExe.class.php
@@ -67,13 +67,6 @@
 {
 
 	/**
-	 * The singleton instance
-	 *
-	 * @var GitPHP_GitExe
-	 */
-	protected static $instance;
-
-	/**
 	 * The binary path
 	 *
 	 * @var string
@@ -102,33 +95,11 @@
 	protected $observers = array();
 
 	/**
-	 * Returns the singleton instance
-	 *
-	 * @return GitPHP_GitExe instance of git exe classe
-	 */
-	public static function GetInstance()
-	{
-		if (!self::$instance) {
-			self::$instance = new GitPHP_GitExe(GitPHP_Config::GetInstance()->GetValue('gitbin'));
-			self::$instance->AddObserver(GitPHP_DebugLog::GetInstance());
-		}
-		return self::$instance;
-	}
-
-	/**
-	 * Releases the singleton instance
-	 */
-	public static function DestroyInstance()
-	{
-		self::$instance = null;
-	}
-
-	/**
 	 * Constructor
 	 *
 	 * @param string $binary path to git binary
 	 */
-	protected function __construct($binary)
+	public function __construct($binary)
 	{
 		if (empty($binary)) {
 			$binary = GitPHP_GitExe::DefaultBinary();

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -146,7 +146,6 @@
 
 GitPHP_Resource::DestroyInstance();
 GitPHP_Config::DestroyInstance();
-GitPHP_GitExe::DestroyInstance();
 
 if (GitPHP_DebugLog::GetInstance()->GetEnabled()) {
 	$entries = GitPHP_DebugLog::GetInstance()->GetEntries();

comments